Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 ssrs 2008 r2 complex iif statement

Author  Topic 

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2013-10-03 : 18:18:27
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?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-10-04 : 02:03:15
yes. your assmuption is correct. It uses a set of nested IIF to check the various conditions.
The above nested iifs can be simplified using Switch statement like

=Switch(Fields!Gr.Value = "01", "01 Total Score" ,
Fields!Gr.Value = "02", "02 Total Score",
Fields!Gr.Value = "03", "03 Total Score",
1=1, "All Levels")

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

jassie
Constraint Violating Yak Guru

332 Posts

Posted - 2013-10-04 : 09:47:03
Thanks!
Go to Top of Page
   

- Advertisement -