Jasper Reports : variables referencing other variables?

Viewed 24

Inside a Jasper report, I'd like to have something with two non-cumulative variables (computed for each record) :

var_age : a calculation of age based upon elements of the current record.

var_sanitized_age : something that takes var_age and changes its value if needed

So far it seems to me that I can't control in which order these variables will be computed. And that this could have var_sanitized_age either use var_age's previous value, or fail.

Is there a way to have Jasper correctly compute one variable, with an expression that uses the values of one or several other variables ?

And as a natural extension to this question, could I define a cumulative variable named var_sanitized_age_average that would reliably average upon one of the variable's latest value ?

1 Answers

Variables are computed in the order in which they are declared in the report/dataset.

Therefore if var_sanitized_age depends on var_age, you need to be declare var_sanitized_age after var_age.

Computing the average of var_sanitized_age as var_sanitized_age_average would also work as long as the variables are declared in this order.

Related