25

I currently have the following 2008 SSRS Report and I want to conditionally format background of the columns based on some logic.

I have three columns and two of which I would like to change the background color. Columns "Current Risk Level", "Trend", "Tolerance". Each contains rows of either Low, Moderate, Medium, High, Very High

For column "Current Risk Level" I would like Low="Green",Moderate="Blue",Medium="Yellow",High="Orange",Very High="Red"

For column "Tolerance" I would like Low="Red",Moderate="Orange",Medium="Yellow",High="Blue",Very High="Green"

I don't know how to set up a SWITCH or IIF function to accomplish this.

Any help would be really appreciated!

AKudla
  • 325
  • 1
  • 3
  • 9

1 Answers1

56

To dynamically change the color of a text box goto properties, goto font/Color and set the following expression

=SWITCH(Fields!CurrentRiskLevel.Value = "Low", "Green",
Fields!CurrentRiskLevel.Value = "Moderate", "Blue",
Fields!CurrentRiskLevel.Value = "Medium", "Yellow",
Fields!CurrentRiskLevel.Value = "High", "Orange",
Fields!CurrentRiskLevel.Value = "Very High", "Red"
)

Same way for tolerance

=SWITCH(Fields!Tolerance.Value = "Low", "Red",
Fields!Tolerance.Value = "Moderate", "Orange",
Fields!Tolerance.Value = "Medium", "Yellow",
Fields!Tolerance.Value = "High", "Blue",
Fields!Tolerance.Value = "Very High", "Green")
Anup Agrawal
  • 6,551
  • 1
  • 26
  • 32
  • It worked great! Thank you so much. I spent forever trying to get this to work. – AKudla Aug 30 '13 at 17:27
  • Glad I was able to help. Please consider marking an answer as accepted if it solved your issue. http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Anup Agrawal Aug 30 '13 at 17:34
  • What if I have 6 rows in my table and I need to change cell colors only for row #3, not for the whole table. How can I do that? Something like = `SWITCH ( IIF(Fields!Underwriter.Value="Brown, Debra" THEN Fields!PoliciesBound.Value = 0, "Tomato", Fields!PoliciesBound.Value >=1 and Fields!PoliciesBound.Value <= 5 , "Yellow", Fields!PoliciesBound.Value >=6 and Fields!PoliciesBound.Value <= 10 , "Gold", Fields!PoliciesBound.Value >= 11 and Fields!PoliciesBound.Value <= 16,"#bdff30", )` – Serdia Jul 07 '16 at 23:33
  • @Oleg iif(RowNumber(Nothing) = 3 , SWITCH() , "White") – KeithL May 15 '19 at 18:31