Alteryx Designer Desktop Discussions

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

Convert String with Hyphen to Numbers

kailash85
6 - Meteoroid

Hi, 

 

Im trying to convert the following string values into numbers:

 

Input StringOutput Double
 - 0
123.2123.2
-1234.2-1234.2

 

I tried using Replace but then the "-" in front of the negative gets replaced as well. Not sure if this can be done with RegEx?

 

Thanks in advance!

K

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

@kailash85 ,

 

Quick Answer:   DON'T USE RegEx!!!!

 

Use a Multi-Field Formula and:

 

Uncheck Copy Output Fields...

Check Change output type to  Double

 

IIF([_CurrentField_]== "-",'0',[_CurrentField_])

 

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Blake
12 - Quasar

Hey @kailash85 , 

 

You can use a conditional formula like the following. 

 

if [Input String] = " - "
then "0"
else [Input String]
endif

 

Blake_0-1606753148476.png

 

Blake
12 - Quasar

Hey @kailash85

 

@MarqueeCrew is right on, just make sure you catch your leading and trailing whitespace in your conditional statement. 

grazitti_sapna
17 - Castor

Hi @kailash85,

 

Here is my take on this problem.

 

grazitti_sapna_0-1606811266074.png

 

I hope it helps.

Sapna Gupta
Labels