So I am aware this has been answered before,
here:
SSRS 2008 - Dealing with division by zero scenarios
and here:
https://sqldusty.com/2011/08/01/ssrs-expression-iif-statement-divide-by-zero-error/
and I'm sure these work for what I need. However, I'm struggling where to put the different parts of the Syntax as
A) I'm not very good at this but I am trying my best!
and
B) The code is awkwardly long
This is my code which produced #Error
=SUM(Fields!OperationalCharge.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalCharge.Value, "WaterBillingData") - Fields!OperationalChargePreviousMonth.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalChargePreviousMonth.Value, "WaterBillingData"))
/ SUM(Fields!OperationalChargePreviousMonth.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalChargePreviousMonth.Value, "WaterBillingData")) * 100
And this is what I have tried:
=Iif(SUM(Fields!OperationalCharge.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalCharge.Value, "WaterBillingData") - Fields!OperationalChargePreviousMonth.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalChargePreviousMonth.Value, "WaterBillingData")) = 0, 0,
SUM(Fields!OperationalCharge.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalCharge.Value, "WaterBillingData") - Fields!OperationalChargePreviousMonth.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalChargePreviousMonth.Value, "WaterBillingData")) / SUM(Fields!OperationalChargePreviousMonth.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalChargePreviousMonth.Value, "WaterBillingData")) * 100 ) = 0, 1,
Iif(SUM(Fields!OperationalCharge.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalCharge.Value, "WaterBillingData") - Fields!OperationalChargePreviousMonth.Value + Lookup(Fields!InvoiceDate.Value,Fields!InvoiceDate.Value, Fields!OperationalChargePreviousMonth.Value, "WaterBillingData"))
However, this then gives me the error:
The Value expression for the Textrun 'Col.name.Paragraphs[0].TextRuns[0]' Contains an error: [BC30205] End of statement expected
I'm half thinking I've actually got this right, however as I've changed it, it doesn't like something in the update from other things I've read while trying to resolve this.
Ideally I want any 0/0
to show N/a
or -
. I'm aware the above code I tried doesn't do this, but when I tried to how this as well, I also came across the same error
Any help would be gratefully received!
Cheers,
Wil