CASE :
0/0 or
23/0
In general,
something/zero will results infinity and causes to divide by zero error in jasper reports. We can handle to have expression value as 0 when denominator is zero.
Example :
$F{number_of_sales}.intValue()==0?0:$F{unit_sales}.intValue()/$F{number_of_sales}.intValue()
Ternary operator usage in Jasper Reports.
NOTE : If you fields are Decimal types, you need to work with methods.
Will update this page for decimals.
:-)
0/0 or
23/0
In general,
something/zero will results infinity and causes to divide by zero error in jasper reports. We can handle to have expression value as 0 when denominator is zero.
Example :
$F{number_of_sales}.intValue()==0?0:$F{unit_sales}.intValue()/$F{number_of_sales}.intValue()
Ternary operator usage in Jasper Reports.
NOTE : If you fields are Decimal types, you need to work with methods.
Will update this page for decimals.
:-)
No comments:
Post a Comment