RowNumber for group in SSRS 2005

FistOfFury picture FistOfFury · Jul 10, 2013 · Viewed 36.4k times · Source

I have a table in a SSRS report that is displaying only a group, not the table details. I want to find out the row number for the items that are being displayed so that I can use color banding. I tried using "Rowcount(Nothing)", but instead I get the row number of the detail table.

My underlying data is something like

ROwId   Team      Fan

1       Yankees   John
2       Yankees   Russ
3       Red Socks Mark
4       Red Socks Mary
...         
8       Orioles   Elliot
...         
29      Dodgers   Jim
...
43      Giants    Harry 

My table showing only the groups looks like this:

ROwId   Team
2       Yankees
3       Red Socks   
8       Orioles
29      Dodgers 
43      Giants  

I want it to look like

ROwId   Team
1       Yankees
2       Red Socks   
3       Orioles
4       Dodgers 
5       Giants  

Answer

Ian Preston picture Ian Preston · Jul 11, 2013

You can do this with a RunningValue expression, something like:

=RunningValue(Fields!Team.Value, CountDistinct, "DataSet1")

DataSet1 being the name of the underlying dataset.

Consider the data:

enter image description here

Creating a simple report and comparing the RowNumber and RunningValue approaches shows that RunningValue gives your required results:

enter image description here