SSRS alternate row colors with column groups
I have reports in SSRS where I can alternate row colors using this expression:
=IIF(ROWNUMBER(NOTHING) MOD 2, "LightSteelBlue","WhiteSmoke")
This works great. However, I have a report that has column grouping and this seems to mess up the alternating row colors.
Grouped columns will alternate column colors instead of row colors. I have searched and found possible solutions with row grouping, but nothing with column grouping, or at least I canโt bring anything to work. I'm just trying to get every other line to be "LightSteelBlue" or "WhiteSmoke", nothing out of the ordinary.
Any ideas?
source to share
Here is the solution I came across:
-
Add a column to the right end of the table and name the text box "RowNumber". Set the visibility to "Hidden".
-
Add an expression to the RowNumber text box.
=RunningValue(Fields!last_name.Value & Fields!entity_name.Value, CountDistinct, "dataset name")
-
Add expression to background color of detail row:
=IIF(ReportItems!RowNumber.Value mod 2 > 0, "LightSteelBlue", "WhiteSmoke")
The RunningValue () function requires unique values. In my case, the member name can be repeated several times due to the same member belonging to different entities. So I combined last_name and object_name to get a unique value.
Hope it helps.
source to share