简体   繁体   中英

SSRS 2008 Expression

I am trying to write IIF statement in SSRS 2008 experssions but can run only one part at a time... the other part gives error... here is what am writing..

=IIF(Parameters!Month.Value = 1,  " "& CStr(MonthName(Parameters!Month.Value +11)) &" " ,  "ABC")

When ever i run this and value of Month parameter = 1 then it runs fine but when value <> 1 then it gives #Error ... The false part is not executing... I think some thing wrong with double quotes...

Even if i change positions of true and false sets...result is same... If i simply write like..

=IIF(Parameters!Month.Value = 1, "CDE" , "ABC")

then it all runs fine...

Please help...

Looks like an assumptive mismatch of metadata. Even though you are calling out CStr() it could be something on that front. Trying wrapping the false statement in CStr() as well as dropping the " " & and & " " and see what happens. That's where I'd start.

There is no issue with the Quotes.

Months are only between 1 to 12. Based on your equation Parameters!Month.Value can only be from -10 to 1 .

If you supply any value greater than 1 or less than -10 or any decimal values you expression will error out. You need to check all the values you are passing in Parameters!Month.Value or change your expression.

Resolved it.....

=IIF(Parameters!Month.Value = 1,
MonthName((((Parameters!Month.Value-1)+11) Mod 12 )+ 1) + "-" + CStr(Parameters!Year.Value - 1), MonthName((((Parameters!Month.Value-1)+11) Mod 12 ) + 1) + " - " + Parameters!Year.Value)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM