SSRS Change Font Color using SWITCH Expression

4/26/2010 9:00:09 PM

I have found that a common behaviour that people want to see in their reports is changing the font color depending on whether or not a value meets, or does not meet certain thresholds. This can be easily accomplished with conditional formatting in SSRS 2008.

We will work with the SWITCH statement to accomplish this. In a previous post where I explained how to get alternating background colors for rows to make the report easier to read, we used a single IIF statement.

Lets use an example from the Adventure Works 2008 Data Cubes again. Shown below. Clean Report

We want to paint the font color:

  • Green if the value is greater than 20,000
  • Red if the value is less than 1,000
  • Balck if the value is less than 20,000

Right click on the texbox that you want to change and click on properties. When the Text Box Properties window opens click on fx in the color section. In here we can enter our expression:

 =SWITCH(Fields!Internet_Gross_Profit.Value < 10000, "Red", Fields!Internet_Gross_Profit.Value < 20000, "Black", Fields!Internet_Gross_Profit.Value >= 20000, "Green") 

And our final should look something like:
Finished Report