Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS Conditional Formatting

I am working on SSRS Ranking report, where Rank 1 should have background of Green and last Rank should have background of Red.

Example below:

SSRS Conditional Formatting

I tried using custom code but that's not working for me as below:

SSRS Expression used as below:

=Code.RankColour(me.value, 1, Fields!RankName.Value)

And RankColor code as below:

Public Function RankColourTotals(ByVal Value As Decimal, ByVal MinValue As Decimal, ByVal MaxValue As Decimal) As String
    Dim strColor As String

    Select Case Value
        Case MaxValue
            strColor = "Salmon"
        Case MinValue
            strColor = "LightGreen"
        Case Else
            strColor = "Gainsboro"
    End Select
    Return strColor
End Function

Note: I am using SQL 2008 R2

like image 652
user2827587 Avatar asked Dec 17 '15 06:12

user2827587


1 Answers

Finally I ended up using function call, so I get flexibility to change color at 1 place instead of changing expression in all the coloumns (if business decides to change color). And my code is as below

Public Function RankColour(ByVal Value As Integer, ByVal MinValue As Integer, ByVal MaxValue As Integer) As String
Dim strColor As String

Select Case Value
    Case MaxValue
        strColor = "Salmon"
    Case MinValue
        strColor = "LightGreen"
    Case Else
        strColor = "White"
End Select
Return strColor
  End Function

And then expression used in column cell as below:

=Code.RankColour(me.value, Min(Fields!AbsenteeismRank.Value, "dataset1"), Max(Fields!AbsenteeismRank.Value, "dataset1"))
like image 89
user2827587 Avatar answered Oct 03 '22 08:10

user2827587