0
votes

I have data in an SSRS report that groups and provides percentages. I need to change the font color for the percentages and I can't figure out how to create the expression.

Currently I obtain the percentage with this formula:

Sum(Fields!Time_Msg.Value)/Count(Fields!Driver.Value)

The Time_Msg field is obtained from SQL. I want the font expression to be the greater of three colors using this formula:

IIF(Fields!Time_Msg.Value = 1, "green",
IIF(Fields!Time_Msg.Value = 0 
And Fields!Time.Value > Fields!TimeB.Value, "red", "yellow"))

So essentially if the record is on time the font will be green, if the record is late then red and early then yellow.

But what do you do when providing grouping sums? If from all the records the greatest value is green, then the font for the grouping sum should be green, etc.

2

2 Answers

1
votes

Sorry for formatting as I'm new to this forum..

go to Textbox properties-> Font -> Color and type an expression like this

Instead of using IIF please try to use Switch statement.

= switch(Fields!Time_Msg.Value = 1, "green",

Fields!Time_Msg.Value = 0 
And Fields!Time.Value > Fields!TimeB.Value, "red")

Note: Put your condition in switch statement.

Let me know if this works

0
votes

You can use custom code in your project

Function SetColor(ByVal Value As Integer) As String

    Dim Ret as string
    Dim doubleVal As Double 
    Ret = "Blue"

    Dim Val As Double 

    doubleVal = System.Convert.ToDouble(Value)


    if Value >= .86 then
    Ret = "OliveDrab"

    ElseIf Value <=.86 then 
    Ret = "IndianRed"

    end if

End Function

assign whatever numbers you want to whichever colours you are using (I'm using greater or less than 86%) and set the font colour expression to =Code.SetColor(Me.Value)