August 25, 2008 at 1:05 pm
I'm trying to figure out the syntax on an RS expression, but keep getting compile error msgs. Example below:
If Title value = "Director" OR Title value = "Mgr" AND IF SupervisorName value = "Jane Smith" THEN "Las Vegas" ELSE IF SupervisorName value = "John Doe" THEN "Ft. Laud" ELSE SupervisorName Value
ELSE
IF Title value <> "Director" AND Title value <> "Mgr" THEN
"No Manager"
What would be the RS syntax for a nested if statement?
thx,
John
August 25, 2008 at 1:39 pm
try using the CASE/WHEN clause, it's well documented in BOL
August 26, 2008 at 8:24 am
John,
Try using SWITCH(). It looks at pairs of comma delimited conditions (first half of pair is check condition, second half is true result) and selects the result based on the first true check condition it encounters.
Here are your conditions organized into a SWITCH expression.
=SWITCH(
(Title value = "Director" OR Title value = "Mgr" ) AND SupervisorName value = "Jane Smith" ,"Las Vegas" ,
(Title value = "Director" OR Title value = "Mgr" ) AND SupervisorName value = "John Doe", "Ft. Laud" ,
(Title value = "Director" OR Title value = "Mgr" ), SupervisorName Value,
Title value <> "Director" AND Title value <> "Mgr", "No Manager"
)
[font="Comic Sans MS"]toolman[/font]
[font="Arial Narrow"]Numbers 6:24-26[/font]
August 26, 2008 at 3:05 pm
Never heard of the SWITCH function but I'll give it a go.
BTW, what's BOL?
thx fellas.
August 26, 2008 at 3:10 pm
BOL is books online (just the help documentation)
I had never heard of switch either.
August 27, 2008 at 6:17 am
Documentation for SWITCH() is here
http://msdn.microsoft.com/en-us/library/dft2z9yf(VS.71).aspx
VB functions in general here
http://msdn.microsoft.com/en-us/library/32s6akha(VS.71).aspx
Happy hunting!! 😀
[font="Comic Sans MS"]toolman[/font]
[font="Arial Narrow"]Numbers 6:24-26[/font]
August 28, 2008 at 7:35 am
Hei,
Reporting server supports conditional statement 'iif' only...not if..
iif(Condition,value if true,vlaue if false)
August 28, 2008 at 7:56 am
RS itself, not SQL Server, writes in VB.Net syntax. If you know that, it makes life easier because you can search for help in Google or books. I use IIF too.
September 3, 2008 at 9:11 am
I believe you would want your syntax to look something like I have listed below;
=iif(Fields!title.value = "Director", "Las Vegas", "Fort Laud")
the "Fields!title.value" is the text box on your report that has the data you want to evaluate, Even though this is just looking at one value. You should be able to nest the conditional "IIF" statement to evaluate multiple statements. You can find the syntax in books-online under "Adding Conditional formatting".
Good Luck!
March 22, 2010 at 8:33 am
Hey Toolman, I like that script lookup, very good!
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply