Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
解決済み

Exchange string with double

Suedseeperle
メテオロイド

I have a Likert Scale with answers '-2, '-1, 0, 1, 2

Excel cannot calculate the AVERAGE and SD with these numbers, therefore I want to change them

'-2 -> 1

'-1 -> 2

0 -> 3

1  -> 4

2 -> 5

I put a SWITCH Formula in Alteryx, but it doesn't work... Do you know where my mistake is?

My syntax is Switch([_CurrentField_],0,''-2',1,''-1',2,'0',3,'1',4,'2',5)

 

 

 

 

 

4件の返信4
alexnajm
16 - Nebula
16 - Nebula

It looks like you are missing quotes around each of the values - in addition because some of your values have apostrophes I would suggest using double quotes

Switch([_CurrentField_],"0",'''-2","1","'-1","2","0","3","1","4","2","5")

alexnajm
16 - Nebula
16 - Nebula

IF you want to force it then to be a Double you could surround the entire thing with ToNumber()

Qiu
20 - Arcturus
20 - Arcturus

@Suedseeperle 
I tested the Switch Function and it works just ok in below.

Another way I would recommend is that Find and Replace tool.

We can have an indexing chart for converting and it is easy to update in case you want to change something.

0630-Suedseeperle.PNG0630-Suedseeperle1.PNG

Suedseeperle
メテオロイド

Great thanks guys that really helped, both solutions work :) 

ラベル