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

conditional sum not working when more than one conditions


dprogrammer

Recommended Posts

Hello Friends, 

I have a veriable that sums of values based upon two conditions. If I use both conditions, the value is coming up 0. However if I only leave one condition, I get a value. What could be wrong?

($F{city}.equalsIgnoreCase ("NEW YORK") && $F{city_zip}.equals (10001) )? $F{sales_amount}:0

I have data where both conditions are true yet the variable is not summing up the values. If I just use one condition in the expression, then I am getting values. Do I need to create group on the condition fields? I am resetting the variable at report level 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Have you already checked, if one of the fields is NULL??

Try to change the order of the expression to: (not sure whether your ZIP is plain int or Integer or String, that's why my convert to String):

"NEW YORK".equalsIgnoreCase($F{city}) && ("10001").equals(String.valueOf($F{city_zip})) ? $F{sales_amount}:0 

by default, Jasper is not null-safe... so you should be aware of correct order for equals-comparisons

hth + regards

C-Box

Link to comment
Share on other sites

  • 1 month later...

Try to change the order of the expression to: (not sure whether your ZIP is plain int or Integer or String, that's why my convert to String):

"NEW YORK".equalsIgnoreCase($F{city}) && ("10001").equals(String.valueOf($F{city_zip})) ? $F{sales_amount}:0

by default, Jasper is not null-safe... so you should be aware of correct order for equals-comparisons

as above answer continuity i am adding this . the mentioned expression should go into variable and use reset sum and average option to get your total . if you need more clarity on this i will send you the sample example

 

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