Create a row grouping in Table Component (Jasper)

Consider an example currently you are showing the data as shown in below using tabular component.

State Person Name Tax Amount
Iowa PQR 10,000
Iowa XYZ 15,248
Utah ABC 14,245
Utah DEF 13,256
Wisconsin GHI 12,789
Wisconsin JKL 11,100

But If you want to show the data as shown in the table.

State Person Name Tax Amount
PQR 10,000
XYZ 15,248
Total 25,248
ABC 14,245
DEF 13,256
Total 27,501
GHI 12,789
JKL 11,100
Total 23,889

For this you need to follow these simple steps.

  1. Create a group in the Groups property of data set (This data set is used by table component).
    Say Country is the name of the group and then put the expression.
  2. Note : Sometime in the Jasper Studio 6.0.1 the name of the group does not change in that case you need to keep the by default name to the group.

  3. After creating the Group you can see the two new bands added to table component. You can see in the figure.
  4. groupShow

  5. Create a cell in Group header and put group expression in it (in my case $F{country}).
  6. In order to calculate the total group wise you need to create a variable with reset type your group name (Country) otherwise you will not get the correct result.
  7. Put this variable (say total) in the group footer.

Note: You can create multiple group in a table.

1 comment

  1. vibhor

    I have tried,but on generation of report its showing null value.

Leave a Reply