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
Author
Message
Posted Thursday, October 3, 2013 4:16 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 8:17 AM
Points: 362, Visits: 422
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


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Friday, July 25, 2014 7:47 AM
Points: 83, Visits: 682
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.

Post #1501507
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse