SSRS Divide By Zero Error

An easy clean way to prevent a divide by zero error is using the report code area.

In the Menu; got to Report > Report Properties > Code and paste the code bellow

Public Function Quotient(ByVal numerator As Decimal, denominator As Decimal) As Decimal
        If denominator = 0 Then
            Return 0
            Return numerator / denominator
        End If
    End Function

To call the function go to the the Textbox expresion and type:


 in this case I am putting the formula at the Group level so I am using sum. Otherwise it would be:


Related Posts

Comments are closed.