Need HELP! Converting Crystal to SSRS

  • I have this code:

    =IIF(Fields!Overtime_Cost.Value <> 0 and Fields!Regular_Earnings.Value <> 0, Fields!Overtime_Cost.Value/Fields!Regular_Earnings.Value,0)

    What happens tho is that my overtime cost is 0 and my Regular Earnings is 0, the code returns an error.

    Any ideas of what to do????

  • I have never had much luck using AND/OR conditional logic inside an IIF. I prefer to nest the IIF statements. Here is how I would write it instead:

    =IIF(Fields!Overtime_Cost.Value <> 0,IIF(Fields!Regular_Earnings.Value <> 0, Fields!Overtime_Cost.Value/Fields!Regular_Earnings.Value,0),0)

    Maybe this will work for you.

  • kathleen.zak (3/23/2011)


    I have this code:

    =IIF(Fields!Overtime_Cost.Value <> 0 and Fields!Regular_Earnings.Value <> 0, Fields!Overtime_Cost.Value/Fields!Regular_Earnings.Value,0)

    What happens tho is that my overtime cost is 0 and my Regular Earnings is 0, the code returns an error.

    Any ideas of what to do????

    This one's easy! Create custom code on the report ...

    Public Shared Function Divide(ByVal value1 As Decimal, ByVal value2 As Decimal) As Decimal

    Dim result As Decimal = 0

    Try

    result = value1 / value2

    Catch ex As Exception

    End Try

    Return result

    End Function

    Then in your expressions, use =Code.Divide(value1, value2)

    The reason why the IIF doesn't work is that both conditions are evaluated even if they aren't run. I don't know why but that's how it is.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply