Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

From String to Number

Cfdiaz2103
8 - Asteroid

Hi Everyone!

 

I would like to know if there's any way to convert a string data to a number, with all thousand and decimal separators

 

Example:

 

Before

1,000,500.23   (String)

 

After

1,000,500.23  (Number)

 

The main idea is summarizing some fields in excel from the output in order to validate totals, due to string data can only be counted

 

Thanks for your response.

 

 

 

24 REPLIES 24
HomesickSurfer
12 - Quasar
Cfdiaz2103
8 - Asteroid

Hi @HomesickSurfer !

 

Well, the thing is I really need both separators (Comma and Point), in order to be summarized.

HomesickSurfer
12 - Quasar

Hi @Cfdiaz2103 

 

The values, as Fixed Decimal number format can be summed.  If imperative to have the commas, I'm sorry, I don't know how to.

apathetichell
18 - Pollux

@HomesickSurfer I don't know if replace recognizes the non-comma "," as "," and without a data sample I can't test it. Assuming it does - TOTALLY. But if replace recognizes the non-comma I don't get why tonumber() doesn't recognize it.

 

To clarify the problem is the non-comma which looks like a comma. Any of these solutions would work with real commas.

HomesickSurfer
12 - Quasar

Hi @apathetichell 

 

I'm using real commas from a text input.  Odd that tonumber() doesn't work.  Workflow attached.

mdsalmankhan89
8 - Asteroid

Hi @Cfdiaz2103 , 

 

Not sure if number data type can be preserved along with the comma separator. 

 

Probably u can do a work around by using a regex : tonumber(REGEX_Replace([Input], "[^0-9.]", "")) and post summarizing,  format the number with comma separators just before generating the output. 

 

Thanks 

apathetichell
18 - Pollux

@Cfdiaz2103Can you post some additional data if you haven't been able to get your numbers to convert?

 

 

 

 

 

Cfdiaz2103
8 - Asteroid

Hi @apathetichell!

 

Sure.

 

Example:

 

The following table contains the Sales for every Client, related to a Customer Segment. Sales is a string field that must be converted to a number, preserving both separators (Comma and point)



Once sales is converted to a number field, I would like to summarize Sales, grouping by Customer Segment. However, comma and point separators must be in.


Since Sales contains string data, it can not be operated arithmetically.

 

I'd appreciate your response.

apathetichell
18 - Pollux

Why doesn't the multi-field changing it to double work? You'll still have commas and a period. It seems fine on my machine.

 

The workflow I posted on Friday should convert your data to numbers including both periods and commas.

apathetichell
18 - Pollux

@HomesickSurfer  I guess i had a typo in my test data -  1,23423,23.23 -  It's not a number - that's why it doesn't work. I don't know if @Cfdiaz2103 tried the multi-field formula version it worked fine.

Labels