sql - Handle divide by zero exception in this SSRS rdlc expression -


the following code showing result nan% if values zero:

=format(((sum(iif(fields!flag.value=1,cint(fields!area1.value),0))) / (sum(iif(fields!flag.value=1,cint(fields!unitarea.value),0))) *100),"n") + "%" 

the simplest way avoid divide 0 error here not create in first place! if replace 0 second return value in divisor iif expression 1, problem goes away.

that said think whole expression simplifying somewhat. if read correctly want determine proportion of area1 within unitarea when value of flag 1. expression written:

=format(     iif(         fields!flag.value = 1,         cint(fields!area1.value) / cint(fields!unitarea.value),         nothing     ),     "percent" ) 

note i've dropped multiplier , instead used format function return result of division percentage (you further removing format function entirely , handling formatting in designer).

you don't have layout expression indentation have, expression builder ignores whitespace , make larger expressions easier read, think habit into.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -