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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 ssrs 2008 r2 complex iif statement
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

332 Posts

Posted - 10/03/2013 :  18:18:27  Show Profile  Reply with Quote
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?

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/04/2013 :  02:03:15  Show Profile  Reply with Quote
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
Go to Top of Page

Constraint Violating Yak Guru

332 Posts

Posted - 10/04/2013 :  09:47:03  Show Profile  Reply with Quote
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000