Skip to content

Instantly share code, notes, and snippets.

@gdzierzon
Created March 5, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdzierzon/d51e4f27b1428a292046d2338efdfba8 to your computer and use it in GitHub Desktop.
Save gdzierzon/d51e4f27b1428a292046d2338efdfba8 to your computer and use it in GitHub Desktop.
SSRS Code to Alternate Color for columns in Matrix
Dim yearGroup = New System.Collections.Hashtable()
Function GetGroupColor(groupName As String, color1 as string, color2 as string) As String
If yearGroup.ContainsKey(groupName) Then
Return yearGroup(groupName)
End If
Dim color = IIf(yearGroup.Count() Mod 2 = 0, color1, color2)
yearGroup.Add(groupName, color)
Return color
End Function
'code to use function if the column group is CalendarQuarter - you want to use the ReportItems collection instead of Fields because of NULL values
=Code.GetGroupColor(ReportItems!CalendarQuarter.Value
,"WhiteSmoke"
,"White"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment