Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Error With Switch Syntax

BLivingstone
5 - Atom

Hello,

 

I am stumped on why I am getting the result of my switch statement.  I am getting an error output on 2 of the 7 outputs.  I am trying to increment up a discount level when my qualifying condition is met.  

 

If [Furthers] = "Yes" Then
Switch([CLR],0,0.2,0.3,0.25,0.4,0.3,0.4,0.4,0.5,0.5,0.6,0.6,0.75,0.75,0.75)
Else [CLR]
EndIf

 

Furthers is a string and only has the values of "Yes" or "No".  CLR is a double type that only has the values .2, .25, .3, .4, .5, .6 & .75.  I am outputting into a new field called New % that is also a double.

 

The ones that are giving me the default output (0) are when the original value = .3 and .6 and Furthers = "Yes".  All other combinations work fine.

 

I've tried reversing the order (largest to smallest) and made it all nested ifs and keep getting the same result.  I've done summarizes on the CLR and there are no other values or numbers further out.


Any suggestions on what I am doing wrong?

3 REPLIES 3
MarqueeCrew
20 - Arcturus
20 - Arcturus

@BLivingstone ,

 

I don't think that you're doing anything wrong.

 

If [Furthers] = "Yes" Then
Switch(ToString([CLR]),0,
"0.2",0.3,
"0.25",0.4,
"0.3",0.4,
"0.4",0.5,
"0.5",0.6,
"0.6",0.75,
"0.75",0.75)
Else [CLR]
EndIf

 

There seems to be a "rounding" issue with how the switch data is evaluated.  I convert the data to string and it works fine.  You should place this into ideas and identify it as a 'bug'.

 

Cheers,

 

Mark 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
BLivingstone
5 - Atom

Thank you!   I will remember that trick for the future.

DanielCh
7 - Meteor

Hi MarqueeCrew

 

What can be wrong with that? I would like to populate empty cells basing on below combined formula, it is populating empty cell by appropriate comment basing on LOCAL ID column ("double" format).  Output column is COMMENTS:

 

 

IF (IsEmpty([Comments])) THEN
(Switch([LOCAL ID],'not signed yet'
,[LOCAL ID]=a,'X not signed yet'
,[LOCAL ID]=b,'Y not signed yet'
,[LOCAL ID]=c,'open'))
ELSE [Comments] 
ENDIF

 

 

for know it is populating empty cell only by "not signed yet" although connected row has in LOCAL ID a or b or even c.

Thanks,

Daniel

Labels