Divide by Zero exception with Formula

Stimulsoft Reports.NET discussion
Post Reply
ryanlio
Posts: 4
Joined: Wed Mar 25, 2009 8:23 pm
Location: Singapore

Divide by Zero exception with Formula

Post by ryanlio »

Hi,
I'm using a text field for calculation. Somehow I'm receiving a divide by zero exception
As a test, this works fine:
{IIF(DS_Forecast.DS_SG35_Forecast.MN_CgAvail== 0,0,(1)/DS_Forecast.DS_SG35_Forecast.MN_CgAvail )}

However, when i subsitute (1) with (Sum(Data1,DS_Forecast.DS_SG35_Forecast.FG_Inv)) into
{IIF(DS_Forecast.DS_SG35_Forecast.MN_CgAvail== 0,0,(Sum(Data1,DS_Forecast.DS_SG35_Forecast.FG_Inv))/DS_Forecast.DS_SG35_Forecast.MN_CgAvail )}
It throws a "Divide by zero exception


Please advise on any workarounds

Also, I will expect the calculation not to happen at all since the divisor is a 0, it should just return a 0. yes?

ryanlio
Posts: 4
Joined: Wed Mar 25, 2009 8:23 pm
Location: Singapore

Divide by Zero exception with Formula

Post by ryanlio »

Sorted out.
"Expressions with condition"

Used this instead
{DS_Forecast.DS_SG35_Forecast.MN_CgAvail== 0 ? 0 : Sum(Data1,DS_Forecast.DS_SG35_Forecast.FG_Inv)* DS_Forecast.DS_SG35_Forecast.Total_Val /DS_Forecast.DS_SG35_Forecast.MN_CgAvail}

This works
Post Reply