Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Switch formula not giving expected results

donnell
6 - Meteoroid

I am trying to return a number if the effective tax rate is between a certain range. Gven that there are multiple criteria, I am using a Switch formula:

donnell_0-1605515755849.png

 

This formula is only returning "1" if below 25 (which is what i want) but otherwise "2" and not taking into account the other criteria. Any ideas why or how to fix this? I've attached the workflow for context - thanks!

4 REPLIES 4
atcodedog05
22 - Nova
22 - Nova

Hi @donnell 

 

I personally feel switch cannot be used over here and usage is also wrong. 

 

Right use of switch is the one mentioned in its syntax. It only compares equal to like Value= A or Value =B

It doesnt work on condition.

 

Switch(Value,Default,
Case1,Result1,...,
CaseN,ResultN)

 

 

Please use elseif block for this scenario.

 

IF condition THEN t 
ELSEIF condition2 THEN t2 
ELSE f ENDIF

 

Hope this helps 🙂


If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

donnell
6 - Meteoroid

Thanks @atcodedog05 - I had tried the If statement with multiple ELSEIFs and it hadn't worked but I obviously had an error in there somewhere - it is working now - thanks!

atcodedog05
22 - Nova
22 - Nova

Glad to hear 🙂

 

Happy to help 🙂 @donnell 

 

Cheers and Happy Analyzing 😀

Mohit_17
6 - Meteoroid

Hi @donnell 

 

could you please share what was the error in your formula, I am experiencing the same issue, and the switch is not working for me. I have attached the screenshot. Thanks. 

Mohit_17_0-1649301820485.png

 

Labels