divide by zero/null workaround in SSRS 2008 report

前端 未结 4 1895
失恋的感觉
失恋的感觉 2020-12-01 17:01

I have a report with a field whose value was the expression:

Fields!TotalPrice.Value/Fields!TotalSlots.Value

Although sometimes TotalSlots

4条回答
  •  失恋的感觉
    2020-12-01 17:22

    Jamie F's answer is correct. As a tip, you can add a function to your report code to make the division 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)
    

提交回复
热议问题