Alteryx Designer Desktop Discussions

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

TRIM/REGEX Replace- multiple values in same cell

lomeoari
7 - Meteor

Trying to remove duplicate values and trim commas in the same cell using regex replace. I am pretty close and keep trying to tweak the formula but am having no luck.  Below is the current formula I am using, and the current vs desired output.  I would like to use regex replace if possible as I am using this in the multi-field formula tool due to applying to many columns. 

 

TRIM(REGEX_Replace([_CurrentField_], '(-?\d+(?:[.,]\d+)?),(?=.*\1)', ''), ',')

 

Below is some sample data. Cells have multiple values separated by commas. 

 

Original Data: 

0,0,67,67,0
-30,-30
0.03,0.045,0.03,0.03,0.045,0.045
1.17,0.37,0.36
1.0588,0.8125,1.3586,1.3586

 

Current output:

67,0
-30
0.03,0.045
1.10.37,0.36
1.0580.8121.3586

 

Desired output:

67,0
-30
0.03,0.045
1.17,0.37,0.36
1.0588,0.8125,1.3586
5 REPLIES 5
Qiu
21 - Polaris
21 - Polaris

@lomeoari 
If you dont insist on using RegEx

0203-lomeoari.PNG

binuacs
20 - Arcturus

@lomeoari another method using RegEx tokenize

 

binuacs_0-1643843645985.png

 

lomeoari
7 - Meteor

Thank you! I have a large dataset with many columns I need to apply this to so thinking regex might be a shorter solution. 

atcodedog05
22 - Nova
22 - Nova

Hi @lomeoari 

 

Solution authors are Happy to help : )

If the solution author's response helps please don't forget to mark it as a solution.

Cheers and have a nice day!

lomeoari
7 - Meteor

Thanks for the response! I am applying this to a large amount of columns so I believe using regex might be an easier route.  

Labels