Jump to content

Summing a field


sugra

Recommended Posts

 

Good day,
 
I need some help with writing an expression. My query pulls data related to all product categories, however I need a field that sums data related only to categories that are equal to 2 specific categories. E.g. Business, Personal. Does anyone have suggestions? I would be very grateful.
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

you could try creating a category group. Then set up the summary variables for that group. Place those variables in the group footer. Now in the "Print When Expression" specify to only print the band when the two categories you want printed comes up ie new Boolean($F{groupName}.equalsIgnoreCase("Business") || $F{groupName}.equalsIgnoreCase("Personal")). And don't forget to sort the values by your group.

Magnus

Link to comment
Share on other sites

Thank you so much for your response.

I tried it and I got a report that printed only values where the product category is  Business and Personal.

Is there anyway that I could have just one field that adds/sums only those records where category = Business or Personal?

Link to comment
Share on other sites

Hi,

not sure if I understand exactly what you are trying to do but it sounds like you want a variable that only counts values of certain grouptypes?

If that's the case then add a new variable. Set it to Calculation Type = Count.

In variable expression field write something like this:

$F{groupName}.equalsIgnoreCase("Business") || $F{groupName}.equalsIgnoreCase("Personal") ? $F{groupName} :  null

 

I hope that helps!

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...