Jump to content
JasperReports Library 7.0 is now available ×

Count groups, not records


ktrinad

Recommended Posts

By: Harald Schmidt - harry79

Count groups, not records

2003-06-17 14:31

I try to count groups within groups and I can find no way to reset the counter if the mastergroup changes. I created a variable of type integer, calc.type system, resettype group, reset group to the group i want to count. my inital value expr. is this (from the tutorial counting cities):

 

($V{hgcount} != null)?(new Integer($V{hgcount}.intValue() + 1)):(new Integer(1))

 

So how do I reset this to 1 if the maingroup changes ?

 

Harry

 

 

 

 

By: Giulio Toffoli - gt78

RE: Count groups, not records

2003-06-18 01:52

 

A way could be this:

 

1. Create a variable with the reset type the group that will contins the groups that you want count

Name this variable i.e. GROUP_COUNT

 

2. Make a new variable with the reset type the group that you want count, name this variable i.e. GROUP_FLAG

 

The idea is add 1 to GROUP_COUNT when GROUP_FLAG is 0. In fact the GRPOUP_FLAG is 0 only one time per each group that you want count. If the GRPOUP_FLAG has a value greater that 0, we are already to the next record in the same group, and GRPOUP_FLAG will be another time 0 when this group changes.

 

Details:

 

GROUP_COUNT :

type Integer

Calculation: none

Expression: new Integer( $V{VARIABLE}.inValue() + ( ($V{GRPOUP_FLAG}.intValue() == 0) ? 1 : 0) )

InitialExpression: new Integer(0)

Reset type: Group

Reset group: you "master group", the group that will contains the groups to count.

 

 

GROUP_FLAG:

type Integer

Calculation: none

Expression: new Integer( $V{GROUP_FLAG}.inValue() + 1)

InitialExpression: new Integer(0)

Reset type: Group

Reset group: the group to count.

 

I hope this helps you

 

Giulio

 

 

 

 

 

 

By: Harald Schmidt - harry79

RE: Count groups, not records

2003-06-18 03:34

Great, that works like I wanted. Very many thanks. And I got translation from latin to roman (1 -> I., 4-> IV.) working. That saves me lots of time.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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