Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

ssrs 2008 r2 complex iif statement Expand / Collapse
Posted Thursday, October 3, 2013 4:16 PM


Group: General Forum Members
Last Login: Wednesday, November 25, 2015 3:37 PM
Points: 440, Visits: 528
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?
Post #1501372
Posted Friday, October 4, 2013 4:12 AM



Group: General Forum Members
Last Login: Yesterday @ 7:58 AM
Points: 132, Visits: 1,087
Yes your assumption is correct.

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

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.

Post #1501507
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse