Friday, 26 February 2010

Colour graduation function - SSRS


I needed to highlight date information dependant on it's proximity to todays date. Using a colour graduation, greater emphasis is placed on dates near todays and those in the future, while less emphasis is placed on historical dates.


I created a custom function:

Public Function MonthColourGraduation(ByVal ActualValue As integer, ByVal NeutralColour As String) As String

Select ActualValue
Case >-1
Return "#FFD2D2"
Case >-2
Return "#FFD5D5"
Case >-3
Return "#FFD9D9"
Case >-6
Return "#FFDDDD"
Case >-9
Return "#FFE1E1"
Case >-12
Return "#FFE4E4"
Case >-15
Return "#FFE8E8"
Case >-18
Return "#FFECEC"
Case >-21
Return "#FFF0F0"
Case >-24
Return "#FFF3F3"
Case >-30
Return "#FFF7F7"
Case >- 36
Return "#FFFBFB"
Case Else
Return NeutralColour
End Select
End Function


and for the table rows background colour:


=Code.MonthColourGraduation((DateDiff("m", now(),Fields!LastEndTime.Value)), "White")
To get the hex colour codes I used:

1 comment:

Dom Horton said...

basic ssrs code below:

=SWITCH(
IsNothing(Fields!OverdueActions.Value), "White",
Fields!OverdueActions.Value > 300, "#B5EAB5",
Fields!OverdueActions.Value > 180, "#BBDEAE",
Fields!OverdueActions.Value > 90, "#C1D3A8",
Fields!OverdueActions.Value > 30, "#C7C8A2",
Fields!OverdueActions.Value > 7, "#CDBD9B",
Fields!OverdueActions.Value > 0, "#D3B295",
Fields!OverdueActions.Value > -7, "#D9A78F",
Fields!OverdueActions.Value > -30, "#DF9C89",
Fields!OverdueActions.Value > -90, "#E59182",
Fields!OverdueActions.Value > -180, "#EB867C",
Fields!OverdueActions.Value > -365, "#F17B76",
Fields!OverdueActions.Value <= -365, "#F87070"
)