posted on Tuesday, December 20, 2005 11:25 PM by bknight

Dynamically Changing the Colors of a Value in Reporting Services

In Reporting Services you can dynamically alter the color of a font by clicking the drop-down box for a font color and selecting Expression. This works well, if you would like to show a red color if your not crossing certain price points and green if your numbers look good. The syntax to perform this type of action would look like this:

=IIF( Fields!ytd_profit.Value < 1,"red","green")

Essentially the above is a clasic IF THEN....ELSE statement. If the profit is less than $0, then turn the color red, otherwise keep it green. The problem comes if you want a third or fourth condition. In this type of situation, you'll need to use the SWITCH statement. This statement in Reporting Services performs the same type of activity as a CASE statement in VB. Here's an example of how you could use the same logic as before but show especially good profit as blue.

=Switch( Fields!profit.Value < 1,"red",
Fields!profit.Value > 0,
"Green",
Fields!profit.Value > 100, "blue")

-- Brian Knight

Comments

# re: Dynamically Changing the Colors of a Value in Reporting Services

Tuesday, July 25, 2006 9:54 AM by Gary Biniak
Thanks, your example of this helped me out with changing group titles. In my case the title is a number and I needed it to be descriptive text. So I used the switch statement to evaluate which number I was on and applied the proper text to the case. Much appreciated, this is similar to the switch statement used in .NET. Couldn't accomplish the same functionality any other way in RS (that I know of). One thought, I guess I could have put the description in one of my fields in my datasource and used that instead...

# re: Dynamically Changing the Colors of a Value in Reporting Services

Thursday, July 05, 2007 8:06 PM by Ram
I want to do it for a matrix repors.For tabluar reports i am using rownumber.but in matrix reports row number is not there.Please advice..i

Finally:i want to give alter native colors to s matrix report...
f possible plz mail me the solution
Mail id:mrraghuram_n@yahoo.co.in

# re: Dynamically Changing the Colors of a Value in Reporting Services

Tuesday, March 18, 2008 7:24 AM by zxevil163
o7Fphi Hi from Russia!