Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Negative numbers converting to null

Usamah22
8 - Asteroid

hello,

 

i have a column with numbers which is currently a string. when i convert it to a double to do calculations the negative values (as below) are being lost and set as null. how can i resolve this?

 

Usamah22_0-1615550667506.png

 

2 REPLIES 2
pedrodrfaria
13 - Pulsar

Hi @Usamah22 

 

This function using the formula tool before changing the data type will fix the error for you.

 

If you only have negative values:

 

Replace(Replace([Field], "(" ,"-"), ")", "")

 

pedrodrfaria_0-1615551224640.png

pedrodrfaria_1-1615551231790.png

 

If you have positive as well, you can do something like this:

 

 

if contains([Field], "(" ) then

Replace(Replace([Field], "(" ,"-"), ")", "") else

[Field] endif

 

 

Pedro

Qiu
21 - Polaris
21 - Polaris

@Usamah22 
Maybe we can do like this.

New Workflow6.PNG

Labels