Jaspersoft BI Tools

iReport,Jaspersoft Design Studio,Jaspersoft Server, Schema Workbench,Analysis,Dashboards, Self Service BI, Domains,Topics,Ad-Hoc Reports, Jaspersoft ETL, Embedding BI,HTML-5 charts, Fusion Charts,JFree Charts,Drill down reports , Drill down Dashboards,Visualize.js, Performance Tuning, D3 Charts, Jaspersoft Customization

Thursday, April 09, 2015

TIP : Handle divide by zero expression in Jasper Reports

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.


:-)