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

Sum or Count on conditional field value


Recommended Posts

By: Tony Hanratty - thanratty

Sum or Count on conditional field value

2006-03-21 20:00

 

I am trying to evaluate the number of fields with a certain value. I have a variable declared with the following definition:

 

(($F{area}.equals("North")) ? new Integer(1) : new Integer(0))

 

I have tried both a SUM and COUNT type, and different evaluation times. But All I get when I print it in the summary band is '0'. What am I doing wrong?

 

Thanks in advance,

Tony.

 

 

 

By: Tony Hanratty - thanratty

RE: Sum or Count on conditional field value

2006-03-21 20:34

 

I worked it out. The required expression in the variable definition is:

 

new Integer($F{areamember}.equals("true") ? 1 : 0)

 

Calculation type:Sum Reset Type:Report

 

In the report itself, set the evaluation time to now and it works.

 

Hope this helps someone else who can't afford the manual. :-(

 

Phew!

Link to comment
Share on other sites

  • 1 year later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

I tried this and it worked!

It also works with NOT

new Integer(!($F{STATUS}.equals("Completed")) ? 1 : 0)

 

How could it work if there is more than one condition.

($F{STATUS}.equals("Completed")

($F{STATUS}.equals("InProcess") ?

 

Thanks

Link to comment
Share on other sites

  • 6 years later...

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