Let us enter the below custom code to our report (Kindly refer to Working with expression section for understanding how to enter custom code to report)
'Function to set the color Public Shared Function SetColor(ByVal RunsMade As Integer) As String SetColor= "Red" If RunsMade > 100 Then SetColor= "Green" End IF End FunctionThe code is simple enough to understand. It will return the color as Red or Green depending on the condition.
Now consider we have designed our report as under (we have already seen this earlier. Henceforth, I am not explaining it again)
Let us select the Data Bar for getting the Chart Data popup. Then right-click on the bar and select Series Properties.
In the Series Properties window, select the Fill tab and click the Expression button (fx).
And in the expression editor enter the below expression
=Code.SetColor(Fields!RunsMade.Value)
That's it. Now if we run the report, we will get the desired result
Kindly note that, we have given some gradient effect to our report for beautification.
No comments:
Post a Comment