tmagalhaes Posted December 11, 2009 Share Posted December 11, 2009 Im trying to migrate a report to Jasper Report.There is one issue I'm having with this migration.The attached picture illustrates the problem.I have 3 columns:The first total is a reference to a field in my query.The second total is the percentage of the first field's value over the sum of all values in that field. I got this second column working by using a report field with Evaluation time = Auto and dividing the field value by the variable used to show the gross total.The expression ended up something like ($F{"Foo"} / $V{"SumOfFoo"})Now comes the problem, that 3rd column.This column shows the running sum of the calculated percentages.Since these kind of Percentages can't be done at the "data model level" in Jasper and must be deferred to the "presentation level" I can't do a Sum of the calculated percentages.I though about calculating this new column without depending on the values on the middle column, but expression would be something like ($V{"SumOfFoo"} / $V{"SumOfFoo"} with the first having evaluation time now and the second evaluation time group. But of course, I can't set different evaluation times for each part of the expression. Setting it to Auto would of course always give me 100%.So, is this even possible?Thanks for your time in reading this. Link to comment Share on other sites More sharing options...
lucianc Posted December 14, 2009 Share Posted December 14, 2009 It is possible, but a little tricky.You will have to create an additional variable that has resetType="None" and copies the SumOfFoo value. Then use $V{NewVar} / $V{SumOfFoo} in a text field with evaluationTime="Auto". The new variable will be evaluated immediately due to its reset type.Regards,Lucian Link to comment Share on other sites More sharing options...
tmagalhaes Posted December 14, 2009 Author Share Posted December 14, 2009 Thanks, just tried it, and that did indeed produce the correct result.I had ended up moving this calculation to the database, but this is a much better solution, even if a little tricky. 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