Hello,
I'm having trouble with the following variable expression in iReport:
($V{CST_ELA_2}.intValue() != 2) ? (($V{CST_ELA_5}.intValue() == 5) ? 5 : 0) : 2
I have 2 integer variables CST_ELA_5 and CST_ELA_2.
I just want to return the smaller of the two values, but I think null values are causing an issue. This expression is only returning values that meet the criteria of 5, otherwise the value is null. Any suggestions?
Christine
1 Answer:
what about something like the following:
$V{var1}.intValue() == null ? -> checks for null in first variable
$V{var2}.intValue() == null ? -> checks for null in second variable
0 : $V{var2}.intValue() -> if both are null, send zero, else if only first is null send second variable
: $V{var1}.intValue() >= $V{var2}.intValue ? -> check if first value is greater or equal
$V{var1}.intValue() : $V{var2}.intValue() -> if first is larger or equal, return first variable, else return second