Share via


SSRS: How to candy stripe a table in SQL Server Reporting Services


Change the background color in the properties of the row to an expression.

=IIF(RunningValue(Fields!YourField.value,CountDistinct,Nothing) Mod 2, "Beige", "White")
=IIF(RowNumber(Nothing) Mod 2, "Beige", "White")

or add the following custom code in the report properties (this version works well for Matrices)

Private Alt As Boolean

Public Function CandyStripe(Optional ByVal NewRow As Boolean = False, Optional ByVal OddColor as String = "Beige", Optional ByVal EvenColor as String = "White") As String
'------------------------------------------------------------------------------------------------
' Purpose:  To candy stripe the detail rows of a report
' Example:  Fill.BackgroundColor = Code.CandyStripe()
' Note:     The first column needs a parameter of "True" passed in example: Code.CandyStripe(True)
'------------------------------------------------------------------------------------------------
    If NewRow Then 
        Alt = Not Alt
    End If
    
    If Alt Then
        Return OddColor
    Else
        Return EvenColor
    End If

End Function

References:
http://disgone.com/2011/01/24/zebra-striping-in-sql-reporting-services/
https://code.msdn.microsoft.com/SQL-Server-Reporting-SSRS-50c4d06b