Alteryx Designer Desktop Discussions

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

How to convert a number to a negative number when the minus sign suffixed?

Anamika
6 - Meteoroid

Hi,

 

I have values that has the negative sign as a suffix instead of a pre-fix. E.g. "100 -" instead of "-100". How can I convert this to (100)? Need help with this.

14 REPLIES 14
Anamika
6 - Meteoroid

Thanks! So this is working on some number and not on others.

 

I have:

 

7,497.63-

4,678.98

203.45-

10.98

11.98

105.63-

 

The result i am getting after using your formula is:

(7)

4,678.98

(203.45)

10.98

11.98

(1)

 

I wonder why the formula is working on few values.

Anamika
6 - Meteoroid

Thanks @DavidP  for your help!

MarqueeCrew
20 - Arcturus
20 - Arcturus

... because I didn't know about the text formatting....

 

The text formula of:

 

If Right([Field1], 1) = '-'
Then '-'+ Trim([Field1],'-')
Else [Field1]
Endif

will work for you.  If you are converting to a number, you'll want:

 

If Right([Field1], 1) = '-'
Then '-'+ Trim(Replace([Field1],",",''),'-')
Else Replace([Field1],",",'')
Endif

Cheers,

 

Mark

 

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Anamika
6 - Meteoroid

@MarqueeCrew  this worked. The regex was splitting but was not changing the position of the "-" 

MarqueeCrew
20 - Arcturus
20 - Arcturus

@DavidP ,

 

No offense taken.  I like alternative approaches.  In this case, with the presence of commas, I actually prefer the text functions.  While RegEx is an expensive text function, I try to avoid some text functions when possible.  Sorry that I came across that way.

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Labels