kcronin Posted December 29, 2010 Share Posted December 29, 2010 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 debt12345 James 40.0012345 Mike 55.00Total debt: 95.00^ ^ ^This is the group footerHow 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? Link to comment Share on other sites More sharing options...
Solution cbarlow3 Posted December 29, 2010 Solution Share Posted December 29, 2010 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 Link to comment Share on other sites More sharing options...
amthomas Posted December 29, 2010 Share Posted December 29, 2010 I am not sure what all you have done besides create a group but I will mention some things that might help. 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: BigDecimalcalculation: sumreset type: groupreset group: account_groupincrement 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. Link to comment Share on other sites More sharing options...
kcronin Posted December 29, 2010 Author Share Posted December 29, 2010 Wow, you get the awesome green + sign from me. That worked like a charm and was exactly what I was trying to do.Thank you for your help. Link to comment Share on other sites More sharing options...
matteusbarbosa2 Posted July 25, 2014 Share Posted July 25, 2014 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). Link to comment Share on other sites More sharing options...
matteusbarbosa2 Posted July 25, 2014 Share Posted July 25, 2014 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. Link to comment Share on other sites More sharing options...
tinshou Posted November 16, 2019 Share Posted November 16, 2019 thank u for sloving my problems Link to comment Share on other sites More sharing options...
cbarlow3 Posted November 18, 2019 Share Posted November 18, 2019 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! :) Link to comment Share on other sites More sharing options...
diegodemetrio79 Posted August 24, 2020 Share Posted August 24, 2020 THANK YOU! Link to comment Share on other sites More sharing options...
soniasbbing01 Posted February 9, 2022 Share Posted February 9, 2022 this post really help me I am from India Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now