3

Below is my code I use in the Color Expression in SSRS 2008 to change the color of the text.

=Switch(Fields!DistanceFromOutlet.Value > 500, "Red",
Fields!DistanceFromOutlet.Value < 250, "White")

How would I say if the DistanceFromOutlet.Value > 250 and < 500 it must be Orange?

So Red text for more than 500.

Orange text for betweeen 250 and 500.

And White text for less than 250.

Pedram
  • 6,256
  • 10
  • 65
  • 87
Etienne
  • 7,141
  • 42
  • 108
  • 160

2 Answers2

5

The Switch function is evaluated from left to right so you can do this:

=Switch(Fields!DistanceFromOutlet.Value <=250, "White", Fields!DistanceFromOutlet.Value <= 500, "Orange", Fields!DistanceFromOutlet.Value > 500, "Red")

What I suspect is that you tried to do this which does not work:

Fields!DistanceFromOutlet.Value > 250 and < 500

That would work if you changed it to be explicit:

Fields!DistanceFromOutlet.Value > 250 and Fields!DistanceFromOutlet.Value < 500
Davos
  • 5,066
  • 42
  • 66
4

Nest two IIfs:

=IIf(Fields!DistanceFromOutlet.Value > 500, "Red", IIf(Fields!DistanceFromOutlet.Value < 250, "White", "Orange"))
lc.
  • 113,939
  • 20
  • 158
  • 187