Search code examples
group-byssrs-2008ssrs-tablix

SSRS Tablix Groupings with NULL as Wildcard


My source query produces something like:

| timestamp                | inUser | outUser | xferUser | taskID |
| 2018-03-01 17:00:00.000  | USER.A | NULL    | NULL     | 1234   |
| 2018-03-02 14:00:00.000  | NULL   | USER.A  | NULL     | 2345   |
| 2018-03-02 15:00:00.000  | USER.B | NULL    | NULL     | 2312   |
| 2018-03-03 12:00:00.000  | NULL   | USER.A  | NULL     | 9283   |
| 2018-03-04 13:00:00.000  | NULL   | NULL    | USER.C   | 1928   |
| 2018-03-04 13:59:00.000  | NULL   | USER.A  | USER.C   | 1883   |
| 2018-03-05 14:01:00.000  | NULL   | NULL    | USER.B   | 9910   |

I'm trying to make a summary table to shows the [Count(inUser)], [Count(outUser)], & [Count(xferUser)] by each user:

| user   | inCount | outCount | xferCount |
| USER.A | 1       | 3        | 0         |
| USER.B | 1       | 0        | 1         |
| USER.C | 0       | 0        | 2         |

I can get this pretty close with the column groupings by inUser, outUser, & xferUser. But I run into issues with the NULL values group together.

I can also do this by have multiple matrix, one for each column, but I'd rather try and combine them as it gives a better visualization for each user over all.


Solution

  • If you can edit your datasource I would suggest formatting the output as follows... (I've left out timestamp values to save me typing!)

    taskID  State       UserID   TimeStamp
    1234    'inUser'    'USER.A' 
    2312    'inUser'    'USER.B.'
    1883    'outUser'   'USER.A' 
    1883    'xferUser'  'USER.C'
    etc...
    

    Then you can build a simple matrix with row grouping by UserID and column grouping by State. The data cell would simply be a count and you're done.