Search code examples
reporting-servicesssrs-2012ssrs-tablix

SSRS Grouping based on parameter


I am trying to group my report based on a parameter but get the following error when I try to run the report

The GroupExpression for the tablix 'Tablix1' contains an error: [BC30311] Value of type 'Microsoft.ReportingServices.ReportProcessing.ReportObjectModel.Parameter' cannot be converted to 'String'

The expression I have got so far is

=IIF(Parameters!ParameterName = "Name", Fields!Field1.Value 
        AND Fields!Field2.Value
        AND Fields!Field3.Value,
    Fields!Field2.Value 
        AND Fields!Field3.Value
    )

What I am expecting the above to do is if the Parameter = Name then group 3 different fields else if the parameter is anything but Name then group on only 2 fields, these 2 fields are also used in the first half of the IFF statement

I guess this is a datatype issue, if so then ideally I would like to fix it in SSRS NOT in the SQL stored procedure but if not then fixing it in SQL is not the end of the world

This may be a very simple question but pretty new to SSRS


Solution

  • Try this ...

    =IIF(Parameters!ParameterName = "Name", cstr(Fields!Field1.Value) + 
                   cstr(Fields!Field2.Value) + cstr(Fields!Field3.Value),
                   cstr(Fields!Field2.Value ) + cstr(Fields!Field3.Value)
    )