SSRS Expression Divide by Zero Error

后端 未结 3 1930
不知归路
不知归路 2020-11-27 05:46

I have a tablix box that has a division expression. When dividing by zero or nulls I get #Error displayed in my report. I tried to create an IIF st

3条回答
  •  旧时难觅i
    2020-11-27 06:34

    You can add a function to your report code that handles the divide by zero condition, this makes it a bit easier to implement in multiple cells, e.g.

    Public Function Divider (ByVal Dividend As Double, ByVal Divisor As Double)
    If IsNothing(Divisor) Or Divisor = 0
      Return 0
    Else
      Return Dividend/Divisor
    End If
    End Function 
    

    You can then call this in a cell like so:

    =Code.Divider(Fields!FieldA.Value, Fields!FieldB.Value)
    

提交回复
热议问题