I have created a SSRS report which shows Hours as column names and dates as row names. Cell values represents the Sales of a specific hour of a specific date.
the table in my report is as follows:
Date |Hour 1|Hour 2|Hour 3|max sales|min sales
4/10/2015| 5 | 10 | 15 | 15 | 5 4/11/2015| 30 | 10 | 20 | 30 | 10
I want Green color background in cell with max sales and Red color background in cell with min sales. the required output will be as follows:
Date |Hour 1 |Hour 2 |Hour 3 |max sales|min sales
4/10/2015|5(Red) | 10 |15(Green)| 15 | 5 4/11/2015|30(Green) |10(Red)| 20 | 30 | 10
I have written a custom code for GetColor as follows:
Function GetCellColor(ByVal minValue As Integer,ByVal maxValue As Integer, ByVal currentValue As Integer) As String
If currentValue = maxValue Then
return "Green"
Else If currentValue = minValue Then
return "Red"
Else
return "WhiteSmoke"
End If
End Function
which returns color based on cell value. I can not pass the maxValue, minValue of a row.
Thanks in advance.
Textfield Properties
. Then goto "Fill" or "Background". Click the Fx Button. There you can add a formula for your background color. To access your custom function use=code.GetCellColor()
to access your datasets useFields!currentValue.Value
. By the way, you could also solve this by using the IIF Function instead of the vb script. – Koryu