Tuesday, March 20, 2012

Baffled trying to display a parameter label

I have two parameters: year and month. The Month parameter includes All, 1, 2, ect..

I tried to display the parameter slected with the following expression:

=IIf(Parameters!DateShippedMonth.Label="All",Parameters!DateShippedMonth.Label,

MonthName(Parameters!DateShippedMonth.Label)) & ", " & Parameters!DateShippedYear.Label

I want it to either display the label (All) or the name of the month. I get an error when All is the parameter selected but not when any month is selected. If I removed the MonthName() function, I don't get an error but I also don't get the month name.

Any ideas?

What error are you getting?

The MonthName takes an integer as MonthNumber. If you are using the parameter label, then I would assume that you are trying to pass a string to the MonthName function.

If you are indeed displaying a number 1,2, 3 etc in the month parameter, then try a CInt function around the label.

BobP

|||I tried both with and without CInt() in the MonthName function. If the parameter selected is a month I don't get an error, which is strange as I SHOULD get an error when I'm NOT using the CInt(). I only get an incorrect input string was not correct format when I add the MonthName function. If I run MonthName alone I get the error on the "All" parameter which is why I tried to pull out the "All" parameter with the IIf|||

It looks like it is validating the MonthName function on it's own, outside the context of the IIF.

So I did this to get it to work:

=IIf(Parameters!DateShippedMonth.Label="All",Parameters!DateShippedMonth.Label,

MonthName(iif(Parameters!DateShippedMonth.Label="All",1,Parameters!DateShippedMonth.Label))) & ", " & Parameters!DateShippedYear.Label

BobP

|||

Thanks. I'll try that. I already wrote some custom code to resolve the problem but this looks easier. Although I think I have to use custom code to translate a fiscal period of, say 4, which is really July of the previous year.

Thanks again!

|||

If you are reporting off of a Data Mart/Data Warehouse, your dimDate dimension should take care of that.

Other wise you can use the TSQL function DateName:

Quarter = DateName(q,@.CurDate)

BobP

|||I'm doing mdx queries from a cube and my dimDate month is in integers. If I change it to month names they don't sort correctly.sql

No comments:

Post a Comment