Jump to content
Changes to the Jaspersoft community edition download ×

Counting Group Occurences


ahullinger

Recommended Posts

I have the Definitive Guide to iReports and I followed those instructions on counting the occurences of a group, but the counts are incorrect once the report is filled.  Numbers show up, but they are counting something other than the counties.

Here's the situation.  I created 2 Report Groups: State and County.  I want to count the number of Counties for each State.  I created a new Variable with Variable Class Type as java.lang.Integer and the Calculation type as Count. 

My Variable Expression is as follows:  ( $V{County_COUNT} != null && $V{County_COUNT}.intValue() == 1 ) ? "" : null

The Initial Value Expression is:   new Integer(0)

The Eval. time is "Group" and the Eval. Group is "County".

Is there something that I'm overlooking or is there another way of solving this? 

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi Ashley,

try this: Create a new variable with

  • Variable Class Type: Integer
  • Calculation Type: Count or Distinct Count (depending whether you want multiple occurences of a county within a state to be counted or not)
  • Reset Type: Group; Reset Group: state (this is actually rather important)
  • Increment Type: None
  • Variable Expression: $F{county} for example if the field class type is comparable or something like $F{county}.getId(), but this depends on your data; However, you should provide a value to identify each country
  • Initial Value Ex

Now you can add a field, for example to the footer of your state group, with the field expression $V{nameOfYourNewVariable} . For the evaluation time works 'Now' as well as 'Band' or 'Group' in combination with Evaluation Group 'county' or 'state'.

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