SSRS expression..help!

  • hello,

    i have a report where i am want to display month name and year in the format like this "january-2009"

    i have numerical values for month and year and i am trying the expression given below.

    I want your help because this expression is not working.

    my expression:

    =iif(Parameters!month.Value + 1 > 12,

    (MonthName(Parameters!month.value +1 -12) & "-" & CStr(parameters!year.value +1)),

    (MonthName(parameters!month.value +1) & "-" & CStr(Parameters!year.value)))

    other suggestions are welcome.

    Thank you

  • I take it that your Month data is numerical and non-repeating, i.e. January of your first year is '1' and January of your second year is '13'?

    Where is your source data coming from - a relational SQL database or an Analysis Services OLAP database?

  • well,it isnt like that.....i have values 1 to 12 for months and 2007,2008,2009....for years,

    i concatinating these two values to get a month and year for example "2" & "-" & "2009 '" (2-2009)

    i want to display this date in the following format.

    january-2009

    i want to display the values for 12 months from the time user input. i.e if user select 2 in month drop down box and 2008 in year drop down box , my report will show monthly data from 02-2008 (feb,2008) to jan2009.

  • source for the data is user input through two drop down boxes, first having 1to12 int values for month and second has int values for year.

  • ekant_alone (7/30/2009)


    source for the data is user input through two drop down boxes, first having 1to12 int values for month and second has int values for year.

    That's not the source of the data, that's just where the user chooses the data they want to see. If your months are only 1 - 12 then I don't understand why you are checking for month values > 12. Presumably you have separate columns for Month and Year (if your database is relational) or Month and Year levels in a hierarchy (if your database is an Analysis Services database), hence why I asked about the source of your data?

    So, going with the above assumptions, something like this should be what you want:

    =MonthName(Parameters!Month.Value) &"-"&Parameters!Year.Value

    Sorry, just re-read one of your posts and noticed that you want to display a 12-month period based on the start date selected. For OLAP-based reports that can be achieved fairly easily using MDX functions such as LastPeriods, Lag, Lead, ParallelPeriod and PeriodsToDate.

    For SQL-based reports you might be better off having StartDate and EndDate parameters for the users to select from.

    The code above is to enable the column headings on the report to show the 'Month-Year' values.

    Regards

    Lempster

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply