简体   繁体   中英

Using AND in Switch Expression in SSRS 2008

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 .

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

嵌套两个IIf

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM