By: Brady Upton | Updated: 2012-02-13 | Comments (10) | Related: > Reporting Services Dynamic Reports
Problem
How can I color code certain entries in a SSRS report? In SSRS you can use data driven expressions to color code certain rows, so check out this tip to see how to accomplish this.Solution
Before we get started, I'm assuming you already have a report created. In this example, I'm using the AdventureWorks database and I'm running a report on Name, Email, Hire Date, Title and Pay Rate. My sample report looks like the following.
Formatting Needs
I want to distinguish three different levels of pay. If the Employee makes $10.00 or less I would like to change the text Red. If the employee makes between $10.01 and $20.00 I would like to keep the text Black and if the employee makes more than $20.00 I would like to change the text Green.
Changing Text Color
First, go to the Design tab of Designer view and select all the fields in which the color of text needs to change. In this example, I'll select all fields.
Next, I'll go to the Properties Window. If you don't see this window you can choose View, Properties or simply hit F4.
In the Properties Window click the arrow beside Color and choose Expression:
In the Expression box type your VB expression and click OK. In this example I'm using the following:
=SWITCH(Fields!Pay.Value <= 10, "Red", Fields!Pay.Value >= 20, "Green")
This expression is saying if the Pay column value is less than or equal to $10.00 change the text Red or if the Pay column value is greater than or equal to $20.00 change the text to Green otherwise leave as is.
After clicking OK, click Preview in the Design view and we can see the report color changes.
Changing Background Color
Also, if you'd like to make the colors stand out more you can change the background of the row instead of the actual text color.
In the Properties window change the text color back to Black and use the above expression in the Background Color:
After saving changes, preview and we can see what the changes look like.
Next Steps
Learn more about SSRS:
- Review the SSRS tutorial and examples click here
- Their are tons of other SSRS tips you can find in the Reporting Services Development Tips category
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2012-02-13