2PTTechnology

The platform that enables you to build rich, interactive communities
Welcome to 2PTTechnology Sign in | Join | Help
in Search

getting #Error using the iiF in the expression because of divide by zero

Last post 07-21-2009, 3:38 PM by twaligora. 0 replies.
Sort Posts: Previous Next
  •  07-21-2009, 3:38 PM 212

    getting #Error using the iiF in the expression because of divide by zero

    in the Expression of a cell i have a formula that does division between two cells and sometimes one of the cells brings back 0 and the formula comes back with "#Error" even when i catch the 0 and put with another iif it bombs so the fix is

     

    on the top menu select Report

    select Report Properties

    click on Code

    and paste in this function

     Public Function Division(ByVal MyFirstVal As Double, ByVal MySecondVal As Double) As Double
            If MySecondVal = 0 Then
                Return 0
            Else
                Return MyFirstVal / MySecondVal 
            End If
        End Function

    Than to call it in your expression use Code.Division(Fields!yourcell1.Value, Fields!yourcell2.Value) i was getting an error that Code was not recognized in the expression but it still worked.

    Here is my expression.

    =iif(Fields!TY_LBS.Value = 0, iif(Fields!LY_LBS.Value = 0, 0, -1), iif(Fields!LY_LBS.Value = 0, 1, (Code.Division(Fields!TY_LBS.Value,Fields!LY_LBS.Value) - 1)))

    i was trying to calculate % between the two columns

View as RSS news feed in XML
Powered by Community Server (Personal Edition), by Telligent Systems