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.

Report image

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?

+3


source to share


2 answers


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.

+2


source


Try using runvalue instead of rownumber, where the field name is a field in your data row:



= iif (VAL (runvalue (fields! yourfield.Value, countdistinct, nothing)) MOD 2, "LightBlueSteel", "WhiteSmoke")

0


source







All Articles