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

Grouping by a matrix depending on a value found via combination of three string columns in ssrs 2008


I have a matrix in ssrs 2008 like:

Id type1    type2    type3
1  low     normal    normal
2  high     low      normal
3  normal  normal    normal

What I would like to do is to group by this table in ssrs 2008, but not any of these columns. I will need to add an additional hidden column called "Total". The rule of this column will be (I dont know how to write it and where in ssrs):

int total = 0;
if(type1<>normal) total++;
if(type2<>normal) total++;
if(type3<>normal) total++;
return total;

And the group by need to be based on this column. So an example below:

Id type1    type2    type3   total(visibility:false)
2  high     low      normal   2
1  low     normal    normal   1
3  normal  normal    normal   0

How can I provide it in ssrs 2008. Any help would be appreciated


Solution

  • Your Total column expression should be:

    =IIF(type1 <> "normal", 1, 0) + IIF(type2 <> "normal", 1, 0) + IIF(type3 <> "normal", 1, 0)
    

    The IFF checks the expression in argument 1 and returns 1 if true (second argument) else 0 (third argument).

    I think you also want to use this as the SORTING expression (in reverse [Z-A] order).