I thought this would be simple, but either it is very simple, or I am missing something.
What I am trying to do is simple: I have a column that is a BigDecimal and this column is in a group that I created within iReport. I want the total for a group footer.
Example:
This is the group header
\\/ \\/ \\/
account number Name debt
12345 James 40.00
12345 Mike 55.00
Total debt: 95.00
^ ^ ^
This is the group footer
How would I be able to get the total of 95.00 through iReport itself since the debt is in a group that is based off of the account number?
4 Answers:
Create a variable called debtSubtotal (for example) and make it the same data type as $F{debt}. Set the Calculation to 'Sum', the Reset Type to 'Group' (and pick the appropriate group from the dropdown), set the Variable Expression to $F{debt} and the Initial Value Expression to 0.
If you also want a grand total for the report, right click the new debtSubtotal variable in the Report Inspector, choose 'Copy', then right click on 'Variables' and choose 'Paste'. It will make a copy of the previous variable, now called 'debtSubtotal_1'. In the Properties pane, change the name to something like debtTotal, and change the Reset type from 'Group' to 'Report'. Leave everything else the same.
Now you can drag a copy of your $V{debtSubtotal} into your group footer band (and set the Pattern and the Horizontal Alignment appropriately) and drag a copy of your $V{debtTotal} into your Summary band.
Hope that helps.
Carl
You said you created a group so you have created a group. I will call this account_group.
This automatically creates a variable for you called account_group_COUNT as a variable but that is not what you are interested in here. You can create a new variable (account_group_SUM) for yourself under the variables.
In this you set these:
variable class: BigDecimal
calculation: sum
reset type: group
reset group: account_group
increment type: None (I think this is correct here)
increment group: (leave blank)
variable expression: here I think you put $V{account_group_SUM}.add($F{debt}) to add up your values. You might have to tinker with this more since I haven't messed with this in awhile.
initial value expression: BigDecimal.ZERO should work here
After adding that variable you should be able to put it as a field into the footer as you expect.
Just do it as cbarlow3 told, create a new Variable with a intuitive name, and edit its params to be like this, considering that your retrieved column is called "value", and it's type is "java.math.BigDecimal":
Variable Class: java.math.BigDecimal,
Calculation: Sum,
Reset Type: Report,
Variable Expression: $F{value},
Initial Value Expression: 0 (or whatever default value you need).
A screen is attached to help you guys. Hope that it helped.
Attachment | Size |
---|---|
![]() | 23.42 KB |
Just do it as cbarlow3 told, create a new Variable with a intuitive name, and edit its params to be like this, considering that your retrieved column is called "value", and it's type is "java.math.BigDecimal":
Variable Class: java.math.BigDecimal,
Calculation: Sum,
Reset Type: Report,
Variable Expression: $F{value},
Initial Value Expression: 0 (or whatever default value you need).
thank u for sloving my problems
The only thing more amazing than the fact that these questions and answers are still available nine years later is that many of these solutions still work! :)
THANK YOU!