Switch not working based on conditions

Hi,
I’m StudioX.
Here’s the screenshot of the Excel file. I need to make 3 cases in Switch. Case 1 should be with Projected Value <10000 . Case 2 should be Projected Value >10000 and <30000 . Case 3 should be >30000
I’m trying this out but it is not working.!

@Prinal_C - You can give evaluate a expression in the switch and the case value is a constant, you can’t dynamic values in the case values…

Here is the some additional reference

1 Like

One way to work around the constant case value is to use the inline version of the If statement.

Put this statement in the expression box:

If (value < 10000, 1,
If (value > 10000 And value < 30000, 2,
If (value > 30000, 3, -1)))

Also, you didn’t specify what would happen if the value is exactly 10000. Would it fall into case 1 or case 2? The same with value = 30000. Is it case 2 or case 3? Update the expression with <= or >= depending where you want them to fall into.

image

1 Like

@ptrobot thank u! this nested ‘If’ in the Expression field is not working in StduioX

I tested nested If in Studio X and it’s working fine for me. The only difference is that referring to variables (saved values) is a little different:

Result after running:

image

See attached file for an example: Main.xaml (7.7 KB)

1 Like

Hi,

Another solution:

Can you try the following expression?

 1+Convert.ToInt32(Saved.Values(Of Int32)("SomeSavedValue")>10000)+Convert.ToInt32(Saved.Values(Of Int32)("SomeSavedValue")>30000)

Regards,

will try this . thank you