Search code examples
reporting-servicesssrs-2008ssrs-tablixssrs-groupingssrs-2008-r2

ssrs column grouping based on a query field


I have a matrix in my report.

The columns of the matrix will be based on the "Code" column in my query.

The different values of Code are A, B, C, D, E, F

I want 3 columns in my matrix:

if the Code is in (A,B) then data will be shown in a single column of the matrix, if the Code is in (C,D) then data will show on a second column if the Code is in (E,F) then data will show on a third column

How can I implement this ? If I create a column group on the Code column it will show 6 columns in the matrix

Thank you in advance Jam


Solution

  • In your DataSet, create a calulated field called something like GroupedCode. Use an expression like:

    =Switch(Fields!Code.Value = "A" or Fields!Code.Value = "B", "AB"
      , Fields!Code.Value = "C" or Fields!Code.Value = "D", "CD"
      , Fields!Code.Value = "C" or Fields!Code.Value = "D", "EF")
    

    Now each row will have a field that puts them in one of three groups as required - in the Tablix you can use this calculated field like any other field; create a column group based on this and you will have your required three columns.