How can I add a thousand separator (comma's) to a number that's in a string field using regex?
e.g. 112982 -> 112,982
Solved! Go to Solution.
slick! Yeah I added $3 to capture larger numbers.
Thanks!
above didn't work quite right. I ended up using this solution:
Regex_replace([Value],"\d{1,3}(?=(\d{3})+(?!\d))","$&,")
In | Out |
112982 | 112,982 |
1129820 | 1,129,820 |
158547639 | 158,547,639 |
54789 | 54,789 |
6598 | 6,598 |
317 | 317 |
21 | 21 |
source: http://regexr.com/2rhmc
While I love it when a nifty REGEX expression can solve the problem the easiest solution in this scenario is to use the ToString() function in the Formula tool:
If you have a look at the Formula tool help file you'll see an example using the 3rd (optional) parameter to tell Alteryx you want comas. The default value is either 0 or blank.
ToString([Number],[Decimal Places],[Do I Want Commas])
Wow! That's nifty!
Hi Garth
Of course, I should have known Alteryx has another, easier solution - and it's in one step which is always a plus :)
Thanks everyone for their input!
I've been working with Alteryx since 2011, and working for Alteryx since 2013. I didn't realize there was an 'add comma' option in the ToString() function 'til last year.
[sorry for the typo]
User | Count |
---|---|
19 | |
15 | |
15 | |
9 | |
8 |