Friday 16 March 2018

Tip: group count variable calculation in jasper reports

Hi,

Group count calculation can be done as follows in jasper reports.

Scenario : 
Report Design:
<GroupNumber>  <GroupBand>
                             <detailband>

Example: 
   IamGroupValue1
         row1_value
         row2_value
         row3_value
2    IamGroupValue2
       row1_value
       row2_value
  IamGroupValue2
      row1_value
      row2_value
      row3_value
      row4_value
...
...
...

Steps:
1) Create your group (lets say Group1 , give the field value by which you want to group by)
2) Observe variables - there it creates a variable called "Group1_Count"
3) Create a new variable of Integer type , let say : groupCount
4) Give below expression for the groupCount variable
      $V{Group1_COUNT} == 1 ? ($V{groupCount} + 1) : $V{groupCount}
5) Put Increment Type= [Group]Group1 and Reset Type =Report and Initial Value=1
6) Pull this variable onto the group header where you want to get it.
7) Run the report observe the group count in output.

Calculation Image: 

Reference : 
https://stackoverflow.com/questions/17480184/how-to-show-the-number-of-group


No comments:

Post a Comment