SSRS Conditional Formatting

自古美人都是妖i 提交于 2019-12-07 20:14:51

问题


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:

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


回答1:


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"))



回答2:


You can do this from a single expression within your text box.

Set the BackgroundColour of your textbox to be

=iif(Fields!myRank.Value = min(Fields!myRank.Value, "DataSet3"),
    "Green",
    iif(Fields!myRank.Value = max(Fields!myRank.Value, "DataSet3"),
        "Red",
        "White"
    )
 )

Will give the result

This is because you are searching the current value of myRank against the maximum and minimum values of myRank within the entirety of your dataset DataSet3.

Please let me know if this solves your problem, or if you require further assistance.




回答3:


I used this simple expression at the 'Font / FontWeight' property in order to switch to Bold all non-zero values:

=iif(Fields!ingresos.Value > 0, "Bold", "Default" )

It works!



来源:https://stackoverflow.com/questions/34327730/ssrs-conditional-formatting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!