Jump to content
We've recently updated our Privacy Statement, available here ×

SUM function only sums results from current page! help!


saman0suke

Recommended Posts

I have a problem, and I don't know what to do right now, the thing is that I'm using the TOTAL function on iReport 3.0.0 in order to sum the total of records from a query, this one is on the COLUMN FOOTER band, the thing is that, when the records uses more than one page, the total appears on page 1 and page 2, and on the first page only shows the sum of the records on that page and on the second one it shows the full total, I need to get rid of the total on page 1, since the only one I'm going to use is the one at the end, please, any advice will be great, thanks in advanced, have a nice day!!!



Post Edited by saman0suke at 01/08/2011 06:56
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

 First thing you'll want to change is that if you only want it to appear on the last page, drag it from the column footer to the summary band.  

Secondly, I suspect that when you dragged the field or variable into the column footer, it automatically set the "Reset type" to "Page", which is why the sum function starts over again for each new page.  Change the reset type to "Report" so that you keep a running total that is never reset.

By the way, although you probably want to do BOTH these things so you can change the display behavior and the calculation behavior, they're independent changes:  you might, for example WANT a running total at the bottom of every page, in which case it would be  appropriate to keep the text field in the column footer or page footer but still force the calculation reset type to "Report" so that the total continues to increase for each page and the grand total appears at the bottom of the final page. 

Hope that helps.  Those Calculation, Reset type (and reset group when you start using groups), Variable expression, and Initial Value Expression properties are all interrelated, and it's a good idea to be VERY comfortable with using them in various combinations, as it will come up a LOT.

Hope that helps,

Carl

Link to comment
Share on other sites

I just changed the "Evaluation time" on the SUM field, from Page to Report, so now I can see the final total, and that's works, I still use the column footer because I need the summary to appear in a new page, and the idea of having the SUM field is to show it right after the main select with all the records finishes, I mean the table with the results, but I still have the problem that I'd prefer to have the final total printed only once when the table population is finished, can I do it? how? thanks!

EDIT: I noticed that I can use "Print when expression" on ColumnFooter band to make it visible only when the main select finishes, but, I don't know how the expression could be written, any idea? I managed to make it work but in a non "correct" way, I made a little subreport that obtains the total number of rows found on the main query, I pass that value to the main report, and on the "print when expression" of Column footer I compare this vale being equal to $VREPORT_COUNT, and works in that way, but I know something better, I would appreciate it, thanks!



Post Edited by saman0suke at 01/10/2011 06:13



Post Edited by saman0suke at 01/10/2011 07:10
Link to comment
Share on other sites

I understand the inefficiency of using a List or subreport that largely duplicates the main query just so you can get a row count, but I haven't found a good alternative if you really need to know the TOTAL row count while you're in an individual detail band.  I hear that using a List with a subdataset gets better performance than a subreport, if that helps.  The following posting has some tips for how to create a list that should closely parallel your need:

http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=81368&topid=81372

Carl

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...