Search code examples
jasper-reports

Get consecutive sequence number in ireport


I need to display row number sequence of each group.

I have used $V{PAGE_COUNT} and evaluation time as now

The report data that I am getting is Group A

1.

2

3

4

...........

page ends ......

Group A

1

2

3

4

page ends ---------

Group B

1

2

3

4

5

page ends....

But my requirement is

Group A

1.

2

3

4

...........

page ends

Group A

5

6

7

8

9

page ends .......

Group B

1

2

3

4

5

page ends....

I need all rows of same group to be continuous sequence. And start sequence from 1 when group is changed


Solution

  • You should use the GroupName_COUNT variable in this case.

    The quote from the JasperReports Ultimate Guide

    When declaring a report group, the engine automatically creates a count variable that
    calculates the number of records that make up the current group (that is, the number of
    records processed between group ruptures).
    The name of this variable is derived from the name of the group it corresponds to,
    suffixed with the _COUNT sequence. It can be used like any other report variable, in any
    report expression, even in the current group expression, as shown in the BreakGroup
    group of the /demo/samples/jasper sample)
    

    More info is here: Data Grouping