You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@hughkelsey I'm not sure why your example doesn't work (all I've done is read it), but if I recall correctly, I think I once did totals by doing a UNION query to add a row to the SQL results and giving Dossier a footer parameter of 1, so that it renders the last 1 row of SQL results as a footer.
Does that make sense?
I do like your idea of doing it in Ruby, though. If you want to debug what's happening in your example, bundle open dossier will let you add puts statements or whatever, and gem pristine dossier will clean up for you when you're done.
In case anyone faces this issue, the problem seems to be that report.results gets called 4 times in the report show, which adds a row each time and recalculates the sum for all previous rows. I found two ways to get around the issue:
Call report.results only once in the report show, save the result in a temp variable - res = report.results, and use that to render the report.
Use an if statement to stop adding rows once the first one was added
Neither of those two solutions seems particularly elegant. I tried using report.results.body and report.results.footers to do the calculation instead but that didn't work since the gem automatically assigns the last N rows as footers then puts whatever is left in the body.
It could be worth considering a way to add N empty footers which the user can then fill as needed instead of splitting one dataset between body and footers.
Hello,
I'm trying to add a total row by adding up values from the results, something like this in my class
This somewhat works however now my report has 2 additional rows:
Total 4546.1
Total 9092.2
The first one is correct, the second is exactly double. Is there a recommended way of adding a total or summary row? Thanks for the help.
The text was updated successfully, but these errors were encountered: