user470091
user470091

Reputation: 41

Change text box color in SSRS based on value

I am creating a SSRS report and I have column named Priority and I want to change background color of that particular box based on the value.

This is what I have tried

=SWITCH(Fields!Priority.Value = Critical, "Red", Fields!Priority.Value = High, "Green", Fields!Priority.Value = Average, "Yellow", Fields!Priority.Value = Low, "Blue")

Error: The BackgroundColor expression for the text box ‘Priority1’ contains an error: [BC30451] Name 'Critical' is not declared.

Thank you

Upvotes: 0

Views: 2779

Answers (1)

C Black
C Black

Reputation: 1008

The values on the right side of your equal signs need to be in double quotes.

=SWITCH(Fields!Priority.Value = "Critical", "Red", Fields!Priority.Value = "High", "Green", Fields!Priority.Value = "Average", "Yellow", Fields!Priority.Value = "Low", "Blue")

EDIT: Just to add a little description in case it's not clear: you need those double quotes since you're comparing to those strings. Bare words in expressions are assumed to be keywords, so when it gets to the word Critical and can't find any keyword associated with that, it doesn't know what to do. If you were comparing numbers, you would not need the quotes, but since you are dealing with strings in this case, you do.

Upvotes: 1

Related Questions