Jump to content
We've recently updated our Privacy Statement, available here ×

creating calculated fields


michael.mccarthy
Go to solution Solved by elizam,

Recommended Posts

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 appreciated

Thanks

Michael

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...