0
votes

I have an SSRS Report that uses an optional parameter called @Month.

If it's null, then the stored procedures return data for the previous month.

If it's a value, it should be the 2 digit month such as "10" for October, and all that works quite well.

I need to add in the Header the name of the month and the year that the report was run for.

So I have added a label to the header, and I want to have my expression write out the month based on the value chosen by the user.

So, for example, if the value is left as null, in which case the data returned is for the previous month (using DateAdd in the stored procs), then in December the label will show for November 2014, or in January 2015 the label will show for December 2014

If the parameter value entered by the user is a month such as 10, I would like to display October 2014.

I have started with the expression builder in VS 2008 Report Designer, but I am stuck.

=" for " & Switch Parameters!Month.Value

Do I need to use Switch, or a Case statement?

1

1 Answers

1
votes

You can use something like this, assuming that when a user enters a month it refers to the current year.

=" for " & IIF(IsNothing(Parameters!Month.Value), MonthName(Month(DateAdd("m",-1,Today()))) & " " & Year(DateAdd("m",-1,Today())), MonthName(Month(Today())) & " " & Year(Today()))