Iif() statement problem when evaluating date report parms in SSRS Reporting on an SSAS Cube
We are trying to display thetwoparameters at the top of our SSRS report (based on an SSAS cube) theuser selects at runtime. The two parameters areFromMonth and Two Month. The default value for both is All, yet they can choose to select numbers 1 - 12 (depending on the month they wish to run the report for).I have added a text box to the top of the report. I would likeit toeither display"All Dates"ifthe From month parameter = "All" elsedisplay month - month (the months the user has selected for the report) This is the expression I have used: =IIF(Parameters!FromInvoiceDateMonthNumberOfYear.Label.ToString = "All", "All Dates", MonthName(Parameters!FromInvoiceDateMonthNumberOfYear.Label) & " - " & MonthName(Parameters!ToInvoiceDateMonthNumberOfYear.Label)) When I preview the report (in BIDS) for All (both From/To Parameters), I get the following error:The Value expression for the textbox textbox16 contains an error: Input string was not in a correct format.Howver, if I select a valid From and To month (for each parameter, the MonthName displays correctly, without error).Do I need to evaluate both the From and To parameters for the first half of the Iif() statement? or is one good enough?
November 11th, 2009 7:02pm

Even evaluating both parameters in the 1st argument of the Iif() statement does not help.
Free Windows Admin Tool Kit Click here and download it now
November 11th, 2009 7:43pm

Hi N11689, Please use the following expression to solve the issue: =IIF(Parameters!FromInvoiceDateMonthNumberOfYear.Label.ToString = "All", "All Dates", MonthName( IIF(Parameters!FromInvoiceDateMonthNumberOfYear.Label.ToString <> "All" ,Parameters!FromInvoiceDateMonthNumberOfYear.Label, nothing) ) & " - " & MonthName(IIF(Parameters!ToInvoiceDateMonthNumberOfYear.Label.ToString <> "All" ,Parameters!ToInvoiceDateMonthNumberOfYear.Label, nothing))) That is because of the Reporting Services will evaluate all arguments of IIF function before the report is processed. So, while the value of FromInvoiceDateMonthNumberOfYear is "All", MonthName("All") will fail. Please feel free to ask, if you have any more questions. Thanks, Jin Chen Jin Chen - MSFT
November 17th, 2009 11:48am

This is what we did. We just wanted to confirm that the statement is doing what we thought. And that is evaluating all the arguments. It just seemed like a lot more work than need be.
Free Windows Admin Tool Kit Click here and download it now
November 17th, 2009 11:15pm

I had a somewhat similar issue, but had to use 1 instead of Nothing for MonthName to evaluate successfully. Here is my selection based on parameters: =CStr(Fields!Year.Value)& " "& Switch(Parameters!Rpt_Prmtr_Resolution.Value= "Q","Qtr"&CStr(Fields!TimeSlice.Value), Parameters!Rpt_Prmtr_Resolution.Value= "M", MonthName(IIF(Fields!TimeSlice.Value<=12,Fields!TimeSlice.Value,1),TRUE), Parameters!Rpt_Prmtr_Resolution.Value= "W", "Wk"&CStr(Fields!TimeSlice.Value)) Sonya L. McKeown
June 7th, 2011 12:58pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics