reporting-servicesssrs-2014

Expression to set Legend SSRS


I have a report query that has "Year" as a parameter. If user selects 2016 in the parameter, the query produces 2016 values in a column named "SelectedYear", and 2015 values in a column called "PreviousYear".

I want the legend for the bar chart to then be 2016 and 2015 respectively. If I go Series Properties - Legend - Expression and I do =Parameters!Year.Value, THIS one gets 2016.

If I do =Parameters!Year.Value - 1 for the other one, the legend name remains the column name instead of 2015.


Solution

  • For the year selected in the parameter the expression takes the value of the parameter as it is and displays it as the legend text with no problem. !param - 1 gave issues.

    SSRS wants the result to be a string but it comes as int. Thanks Alan Schofield for making me think about this. In this case the integer must be converted to string so the correct expression is:

    =CStr(Parameters!Year.Value - 1)
    

    This needs to be in the Series properties - Legend