michael.mccarthy Posted September 24, 2014 Share Posted September 24, 2014 hi i have a number of fields in my data set which are set to 1 or 0 depending on whether or not it is true or false. i want to sum these together for a partiular day or for a series of days. at the moment i have set the field to be a measure in my ad hoc view but the only options i have are count all or count distinct and neither will sum. alternatively i have gone back to the domain and tried to create a calculated field to do this however i am having no sucess.there are two possible ways this could work - firstly and more easily if its possible to do this in the ad hoc view.alternatively if i could do this in the calculated field section in the domain. do you have a list of expressions that i can use here? its not very clear what type of code i am to use here.i am new to Jaspersoft and trying to use it for reports within my company.Any help would be appreciatedThanksMichael Link to comment Share on other sites More sharing options...
Solution elizam Posted September 24, 2014 Solution Share Posted September 24, 2014 Presumably it won't sum because under the covers your field is not a number. It is really a Boolean, and is just saying T/F.You could make a calculated field in the domain based on your existing field, and set the zeros to NULL using IF. I think this should work:(IF(YourField), 1, NULL)This sets the new field to 1 if YourField is 1 (True) and to NULL if YourField is 0 (False)You can then use Count as the Summary function, and it will count the non-NULL values only. Link to comment Share on other sites More sharing options...
michael.mccarthy Posted September 25, 2014 Author Share Posted September 25, 2014 the fields are integers and therefore should sum. is there a link to how to create these expressions for calculated fields? i can't find anything on this. also is it not possible to do this in the ad hoc view. i am using jaspersoft server on AWS thanks michael Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now