Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

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

Removing $ from strings

katieshore
6 - Meteoroid

Hi, all. I am still pretty new to Alteryx and constantly learning. I am stuck trying to remove the "$" from my string records in a particular column. 

 

I am using the below formula (picture attached) in my formula tool, but it is turning my negative values into "0", which is not what I want: I would like a number ($908.68) to be -908.68.

 

From that point, would I use a "Select" tool to then convert the string into a number? I need two decimal points to appear (since this is currency) so what data type should I use to see two decimal points (even if it is a whole number like 40 - I would want to see 40.00). 

 

CORRECTION: My formula should say TrimLeft([Amount], "($"). My apologies!

 

 

Thanks!

8 REPLIES 8
echuong1
Alteryx Alumni (Retired)

You can use replace statements to remove the parenthesis and dollar symbol. I used a conditional statement to add a negative if there is a parenthesis present.

 

I also used tonumber() to make the value a number. The precision has a scale of 2, for 2 decimal places.

 

echuong1_0-1613662513899.png

 

apathetichell
18 - Pollux

Here is  a two part formula - the first takes a string, removes the "$" and converts it to a fixed decimal. Hypothetically this should create a whole number with two trailing zeros - but it doesn't on my experiments.

 

I've included a second formula which would take a fixed decimal and convert back to a currency string and add back the zeros for whole numbers.

 

 

Hope this helps.

katieshore
6 - Meteoroid

This works beautifully, thank you!

 

Would you have any idea why the Select tool would remove any zeroes after the number? For example, the formula would give me 50.00, but the Select tool output would only show 50. The same thing is happening for numbers like 40.80, which would come out of the Select tool as 40.8. 

 

I wonder if it has anything to do with the fact that I'm working with over 2 million rows of data, but I'm not sure... Thanks so much for your help!

echuong1
Alteryx Alumni (Retired)

Ensure the datatype is set to a fixed decimal with a scale of 2. I'm guessing your datatype is set to something like float or double, and that is why it's removing the extra zeros.

 

echuong1_0-1613666488699.png

 

katieshore
6 - Meteoroid

That's what I was thinking, but my data type is set to FixedDecimal 19.2 in the Formula tool and in the Select tool... Not really sure what's going on.

apathetichell
18 - Pollux

I'm seeing the same issue where the select tool compresses the decimals on fixed decimal.

katieshore
6 - Meteoroid

That's a good fix. I'm needing the values to be numeric for calculations, though, so I'm not sure that will work for my case. Thank you for your suggestions!

Sir_Paul
5 - Atom

Hi all!  I've run into an issue:  I attempted to remove "$" from my financial data; however, not all the values transferred correctly (see attached).  Do I need to adjust the fixed decimal callibration in my formula tool?  Please advise.  Thank you!

 

Dollar sign removal formula.PNG

Dollar sign removal error_Alteryx.PNG

Labels