Home > front end >  SSRS and Fill Expressions
SSRS and Fill Expressions

Time:11-01

I am fairly new to SSRS and am trying to set some conditional fills on my report but I cannot seem to get it to work.

I am using the following expression:

=SWITCH(Fields!Mandrel_Speed_Actual.Value = 0, "red", Fields!Mandrel_Speed_Actual.Value > Fields!T_Mandrel_Speed_High.Value or Fields!Mandrel_Speed_Actual.Value < Fields!T_Mandrel_Speed_Low.Value, "Orange", "White" )

It seems to work when it comes to filling the fields with orange or white but when I have a field with "0" it says white and won't go orange. What am I missing here?

I've tried using if and putting these in various order but I cannot get it to work with all three conditions. One always fails to apply.

CodePudding user response:

The SWITCH function needs pairs of arguments. The first is the comparison expression and the second is the result if true.

The last arguments in your expression just had the result, not the comparison expression. It helps if you format the SWITCH to show each pair on a single line.

=SWITCH(Fields!Mandrel_Speed_Actual.Value = 0, "red", 
        Fields!Mandrel_Speed_Actual.Value > Fields!T_Mandrel_Speed_High.Value or Fields!Mandrel_Speed_Actual.Value < Fields!T_Mandrel_Speed_Low.Value, "Orange",
        True, "White")

You just needed an expression before the "White". TRUE always meets the criteria makes the final part of the SWITCH perform like an ELSE statement in a CASE.

  • Related