SSRS – Alternate Row Colors of A Group

SSRS – Alternate Row Colors of A Group

This has always been a challenge in Reporting Services – you’ve tried using this standard alternate row shading for a group but the alternation doesn’t work as expected:

=IIF(RowNumber(Nothing) Mod 2, "WhiteSmoke", "White")

For a Tablix Group, do the following:

  • Click Report >> Report Properties (or right click outside the bounds of your report within Design view and select Report Properties)
  • Click the Code tab and enter this custom function:
Public _evenRow As Boolean
Public Function EvenRow() As Boolean
_evenRow = Not _evenRow
return _evenRow
End Function

  • Right click your Tablix Row Group and select Row Group >> Group Properties.
  • Click the Variables tab and Add a new group variable.
    • Name: EvenRow
    • Value: =Code.EvenRow()
  • Now, instead of using the standard IIF(RowNumber… expression for the background color, use this expression for the background color of the row:
=IIF(Variables!EvenRow.Value=TRUE,"WhiteSmoke","White")

As far as I know, the moment you sort your group by an aggregate [Count(id)] the method fails. Otherwise, works great!

I am still trying to figure out how to get around this.

Mike250

Australian. Sport. Passionate Cricket Fan. Go Pro. Abseiling. Snorkeling. Travel. Golf R. SQL Server Developer. Three sons. One daughter. Last Trip: New York.

Related Posts
Leave a comment

Your email address will not be published. Required fields are marked *