SSRS incorrectly renders an Expression as #Error

  • Some of my new reports include an Expression on the page.

    When the report comes back it shows #Error on every line.

    But when I advance to the second page it shows the correct values for the expression.

    And when I go back to the first page where it was showing #Error, it shows the correct values.

    Obviously we can't put a report into production when it behaves like this.

    Is this a bug which experienced SSRS programmers are familiar with?

    Does anybody know what causes it? or how to resolve it?

  • You will have to give more information. Can you post a screenshot, as well as the expression you are using?

  • Expression is very simple:

    =iif(Fields!DEATHSTATUS.Value="DEATH","died "&Fields!DEATH_DATE.Value," ")

    The last few hours I tried running my program to obtain an image. Now that I've finally obtained an image I find this web site does not allow me to paste it and I can't figure out how to get "Insert Image" to work. (On Tuesday I think I'll be able to find a coworker to show me how to do that.)

    I'm getting the impression, however, that the bogus response only happens when the expression evaluates to the 'then' condition. When I run on a test database where the 'then' never happens the #Error doesn't appear.

    The other two programs where I'm encountering this problem have more complex IIFs, and evaluate to something on every line.

  • david.kratz (12/23/2011)


    Expression is very simple:

    =iif(Fields!DEATHSTATUS.Value="DEATH","died "&Fields!DEATH_DATE.Value," ")

    The last few hours I tried running my program to obtain an image. Now that I've finally obtained an image I find this web site does not allow me to paste it and I can't figure out how to get "Insert Image" to work. (On Tuesday I think I'll be able to find a coworker to show me how to do that.)

    I'm getting the impression, however, that the bogus response only happens when the expression evaluates to the 'then' condition. When I run on a test database where the 'then' never happens the #Error doesn't appear.

    The other two programs where I'm encountering this problem have more complex IIFs, and evaluate to something on every line.

    I think the problem here is with the date field. Whenever you combine fields with different data types, you have to ensure that you explicitly cast them to the same data type.

    Try this and see if it works:

    =iif(Fields!DEATHSTATUS.Value="DEATH","died "& cstr(Fields!DEATH_DATE.Value)," ")

  • Thank you. I experiment with that.

    (The odd thing is that when I advance to page 2 it shows me "died " and whatever date is there whenever the criterion is met. So it's like SSRS is saying 'aha, there's a potential error but it's not an error so I'll just pretend it's an error on the first page to get the user's attention but then allow the user to see the desired info' .)

  • Yeah, it does seem pretty strange. Also check for NULLs, because that could also cause some issues when combined with something else.

  • Veteran, thank you for your guidance.

    I changed my Expression as you advised and my problem seems to have gone away.

    =iif(Fields!DEATHSTATUS.Value="DEATH","died "&iif(isNothing(Fields!DEATH_DATE.Value)," ",Fields!DEATH_DATE.Value)," ")

    I'll check my other reports exhibiting this problem to see whether a similar solution works there.

    Thank you for advising me even though I was unable to provide a screen shot.

    And I whole-heartedly accept the assigned moniker of 'grasshoper'. LOL:-)

  • No problem, glad I could help.

Viewing 8 posts - 1 through 7 (of 7 total)

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