pmaslov Posted October 25, 2006 Share Posted October 25, 2006 I am running an SQL query in Jasper report and I need to evaluate an expression Foo(field, sum(field)) for each record. Problem is that I cannot use SQL to get SUM , I need my Jasper report to calculate it. I made a variable that calculates the SUM. I am able to display the SUM in a Text Filed with Report Evaluation Time. Now - how do I use SUM in expression evaluated for each record like Foo( field,sum(field)) ?If it is not possible, then what would be a possible workaround? Thanks!!!!!! Pavel Link to comment Share on other sites More sharing options...
lucianc Posted October 25, 2006 Share Posted October 25, 2006 By sum(field) do you mean the the sum of the field values for all rows? What is Foo (Java class method, ..)? Regards,Lucian Link to comment Share on other sites More sharing options...
pmaslov Posted October 25, 2006 Author Share Posted October 25, 2006 Yes, sum(field) is a sum of all field values in all rows. My SQL is a stored procedure call, so it seems I cannot just do sum in SQL.And yes, Foo() is a java method in my Scriptlet. Thank you!Pavel Link to comment Share on other sites More sharing options...
lucianc Posted October 25, 2006 Share Posted October 25, 2006 If you want to evaluate Foo(field, sum(field)) to display the result in a text field, you can use the "Auto" evaluation type (available since JR 1.2.0). This is the only feature that allows you to evaluate a expression at several points in time (the field should be evaluated immediately, but the sum needs to be evaluated at the end of the report fill). Otherwise, you'd need to somehow (e.g. separate query) compute the sum before iterating the report rows. HTH,Lucian Link to comment Share on other sites More sharing options...
pmaslov Posted October 26, 2006 Author Share Posted October 26, 2006 "Auto" evaluation time is excactly what I was looking for. You are the best! Thanks again! P.S. here is another post about the "Auto" evaluation: http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=view&id=10637&catid=8&limit=6&limitstart=0 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