Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Exchange string with double

Suedseeperle
6 - Meteoroid

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 REPLIES 4
alexnajm
18 - Pollux
18 - Pollux

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
18 - Pollux
18 - Pollux

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

Qiu
21 - Polaris
21 - Polaris

@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
6 - Meteoroid

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

Labels
Top Solution Authors