简体   繁体   English

SSRS 中作为颜色表达式的 Switch 语句

[英]Switch statement as a color expression in SSRS

I´m stuck on a color expression using a switch command.我使用 switch 命令停留在颜色表达式上。

I want to be able to set the color green if the following is true.如果满足以下条件,我希望能够将颜色设置为绿色。

=Switch( Fields!direction.Value = "North" and (Fields!transport.Value = "Car" and Fields!units.Value >= 1) and (Fields!transport.Value = "Bike" and Fields!units.Value >= 2), "Green", 
        1=1, "Red"
)

Is it possible to use that many "and" in a switch statement?是否可以在 switch 语句中使用那么多“and”? Is there a better way to write this code, maybe to include a iif statement?有没有更好的方法来编写这段代码,也许包括一个 iif 语句?

You need to explain the conditions and the desired results to get a real answer but this might help you understand where the problem is..您需要解释条件和期望的结果才能得到真正的答案,但这可能有助于您了解问题出在哪里。

Assuming you want to test if假设你想测试是否

1. Direction is north
2.a. transport is car and units is >= 1
2.a. transport is bike and units is >= 2
and then return "Green", other wise return "Red"

Then the change is quite simple那么改变就很简单了

=Switch( 
        Fields!direction.Value = "North" 
            and (
                    (Fields!transport.Value = "Car" and Fields!units.Value >= 1) 
                    OR
                    (Fields!transport.Value = "Bike" and Fields!units.Value >= 2)
            ), "Green", 
        True, "Red"
)

All I did here was to make the transport/units check a single test with two conditions, if either ( OR ) is true then that part is True I Also replace the 1=1 with True but 1=1 will work the same, they both return True我在这里所做的只是让传输/单元检查具有两个条件的单个测试,如果任一 ( OR ) 为真则该部分为真我也将1=1替换为True1=1将工作相同,他们都返回True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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