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.
Leave a comment