#Error using Expression

  • Greeting,

    I have the following expression that is return #Error when the data contains a 0/0. I have tried several changes to the expression, no of which worked - UGH. Any suggestions would be helpful.

    = IIF(Fields!Presentations.Value = 0, "00:00:00", Format(DateAdd("s", (Fields!TalkTimeSeconds.Value/Fields!Presentations.Value), "00:00:00"), "HH:mm:ss"))

    Thank you,
    Cervello

  • You've posted this in a T-SQL forum, but this is not T-SQL.  I'm guessing SSRS.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Hi Drew,

    You are absolutely correct!!
    I'm working in many different environments and obviously had a moment of brain fog :). Thank you for pointing that out.

    Cervello

  • SSRS sometimes has a bad habit of resolving both sides of an expression inside an iif. That means that even though you're checking for a 0, it's still calculating that equation, which results in 0/0.

    I have had this problem before, but I thought that the problem went away when we upgraded from BIDS to SSDT (2012). Do you have the same problem using a Switch statement?
    =Switch(Fields!Presentations.Value = 0, "00:00:00", Fields!Presentations.Value <> 0, Format(DateAdd("s", (Fields!TalkTimeSeconds.Value/Fields!Presentations.Value), "00:00:00"), "HH:mm:ss"))

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

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

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