So I want to calculate the difference of last month and this month usage of data in my report. Both are decimal. I have this expression in my report
IIf(Fields!LastMonth.Value=0, ((Fields!ThisMonth.Value-Fields!LastMonth.Value)*100), Floor(((Fields!ThisMonth.Value-Fields!LastMonth.Value)/Fields!LastMonth.Value)*100)) * " %"
this statement keep returning #Error and I try to simplify the statement to
IIf(Fields!LastMonth.Value=0, "0","NOT 0")
and it returns 0 right, which means that it falls to right condition.
I guess the statement Floor(((Fields!ThisMonth.Value-Fields!LastMonth.Value)/Fields!LastMonth.Value)*100)
causing the error, because divide-by-zero error encountered.
What I don't understand is, I state the condition if lastMonth.value is 0 it will fall to the first condition, which is no divide-by-zero condition could be caused. Why the second condition affect the whole statement causing error? I thought that the second statement won't be reached because it will fall to the first condition, right?
Can anybody explain it? Or is there any best way to avoid this divide-by-zero condition?
Best regards.
=Fields!Saldo.Value*100/Fields!CostoNeto.Value
– rodrigo.rodriguez