0

I have below Expression which I am using in my report

            =IIF((Sum(Fields!Starts.Value)-Sum(Fields!Withdrawn.Value))=0, Nothing,
(Sum(Fields!Starts.Value)-Sum(Fields!Withdrawn.Value))/(Max(Fields!Year1Starts.Value)))

When I run the report I am getting below message and appears as #Error

    Warning 1   [rsRuntimeErrorInExpression] 
    The Value expression for the textrun ‘Textbox110.Paragraphs[0].TextRuns[0]’ contains an error: 
Attempted to divide by zero.

I tried this but getting same error:

    =IIF((Sum(Fields!Starts.Value) - Sum(Fields!Withdrawn.Value)) = 0, Nothing, 
(Sum(Fields!Starts.Value) - Sum(Fields!Withdrawn.Value))/ 
IIF(Max(Fields!Year1Starts.Value)=0,1,Max(Fields!Year1Starts‌​.Value)))

Can anybody please help?

Aruna

Aruna Raghunam
  • 903
  • 7
  • 22
  • 43

2 Answers2

3

I tried this and it works:

    =IIF(Max(Fields!Year1Starts.Value)=0,0,(Sum(Fields!Starts.Value) 
    - Sum(Fields!Withdrawn.Value))/IIF(Max(Fields!Year1Starts.Value)=0,1,
Max(Fields!Year1Starts.Value)))

I followed this:

=IIF ( Denominator = 0, Nothing, Numerator / IIF( Denominator = 0, 1, Denominator) )
Aruna Raghunam
  • 903
  • 7
  • 22
  • 43
1

You have to handle divisor and prevent it from getting 0 as a value. Something like:

=IIf(Fields!SomeField.Value = 0, 0, Fields!SomeOtherField.Value / IIf(Fields!SomeField.Value = 0, 1, Fields!SomeField.Value))

This will replace 0 with 1 in divisor and thus avoid this error.

ser_nicky
  • 326
  • 1
  • 5