Alteryx Designer Desktop Discussions

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

Regex for formatting numerical values

jl4357
6 - Meteoroid

Hi there,

 

I am struggling to build a regular expression to help with a scenario.

I have a column, string type, that has various kinds of data. I am looking to format the numeric values in this column like so: 12345.6789 to $12,345.68. I included a screenshot of sample data, before and after, below.

 

Does anyone know how to achieve this formatting?
Thank you for your help!

 

Screenshot data.png

3 REPLIES 3
caitlynmcintyre
9 - Comet

Hello!

 

You can use the formula tool with this

 

IF Contains([Before], '%') THEN [Before]
ELSEIF REGEX_Match([Before], '\d+\.?\d*') THEN '$'+ToString(ToNumber([Before]),2)
ELSE [Before]

ENDIF

Screenshot 2023-09-15 134742.png

 

 

caltang
17 - Castor
17 - Castor

Err I recall seeing this post a few days ago. I think it was solved by @binuacs already right?

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
jl4357
6 - Meteoroid

Correct, this was already solved - sorry for the confusion! My original post did not go through, but seems to have now posted several days later :)

Labels