ssrs 2008 r2 complex iif statement

  • In an ssrs 2008 r2 report, I found the following expression that I am trying to understand what it means:

    =iif(Fields!Gr.Value = "01", "01 Total Score",

    iif(Fields!Gr.Value = "02", "02 Total Score",

    iif(Fields!GradeLevel.Value = "03", "04 Total Score",

    "All Levels"))))

    I think it means the following

    If Fields!Gr.Value = "01", then value = "01 Total Score",

    else If Fields!Gr.Value = "02", then value = "02 Total Score",

    else If Fields!Gr.Value = "03", then value = "03 Total Score",

    else (for anything else, the value is "All Levels".

    Can you tell me if my assumption is true or not? If not, would you tell me what this statement really means?

    Also would you point me to a url that explains this kind of logic structure for ssrs 2008 r2?

  • Yes your assumption is correct.

    For readability this could be better done as a switch statement:

    =Switch(

    Fields!Gr.Value = "01", "01 Total Score",

    Fields!Gr.Value = "02", "02 Total Score",

    Fields!GradeLevel.Value = "03", "04 Total Score",

    true, "All Levels"

    )

    Switch evaluates the conditions in order and stops when the first one is true.

    The true condition at the end means this value will always be returned if none of the other conditions have been true.

    Don't know any URLs but you seem to understand what it's doing anyway.

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

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