iReport Error evaluating expression

We are using 5.0.1, and have converted many of our Crystal Reports projects over to iReport/Jasperserver and are happy with the results so far.

I am converting a summary report now that has variable fields in the detail section, multiplying a combination of integer fields and float fields from the database.  I am suppressing the detail section using the Print When Expression, and have created 3 variables to sum the total of the 3 associated variables in the detail section.

The business rule is to round the result in the summary, so, in the Variable Expression of the 3 summing variables in the group footer, I am wrapping Math.round() around the variable name from the detail section in all 3 of the summary variable properties.  Two of them work flawlessly, one does not.  We have double and triple checked to make sure that the summary variables have exactly the same properties, even copying from the working one(s) to the non-working and then renaming.  We have checked the Variable Class to make sure it is Float datatype, and we have checked the data to make sure there are no NULL, empty string, or character data where there should not be.  I have also run the report using the Empty Datasource, and it compiles and runs, but obviously with no results.

If I remove the Math.round() wrapper, the report will compile and run with the other two summary variables rounding fine, but as soon as I add the wrapper function to the 3rd variable, the report throws an error: Error evaluating expression...then flags Math.round(LCIncr_Total), which is the offending variable name.  I will attach the .jrxml and .jasper files to this request.

Any assistance is appreciated greatly...

M. Snyder

marlin_snyder's picture
Joined: Jan 31 2013 - 4:37pm
Last seen: 3 years 2 months ago

1 Answer:

The order in which your Variables are defined matters.  Since the LCIncr_Total actually uses LC_Increase, LC_Increase needs to appear before LCIncr_Total.  In the report inspector panel, you should be able to just grab the LC_Increase variable and move it up higher in the list (before LCIncr_Total, but after LCUpPrice since LCUpPrice is used to define LC_Increase).

Try that and see if it solves things for you.

mgeise's picture
Joined: Mar 5 2007 - 6:18am
Last seen: 3 years 9 months ago

Excellent! Thanks much for the pointer, that worked perfectly. I did find a 'workaround' by clicking directly on the field in the report, I was able to apply the rounding function at that level (certainly after the variable has been evaluated, so going around the issue I was having), and it worked. I have now removed that field level formatting and applied it to the variable after moving the dependent variable up in the list.

Thank you again,

M. Snyder

marlin_snyder - 10 years 7 months ago


marlin_snyder - 10 years 7 months ago