Hi All,
I know this could be a simple solution but I need help as I am quite new to Alteryx.
My input file has 100s of column headers and some column headers are repeated multiple times. I want to give a unique numbers to each column headers because I want to reconcile them. In excel I am able to perform that step by using the below formula.
A2&"/"&COUNTIF(A$2:A2,A2) (A2 value being 1)
See sample of what I am trying to achieve in alteryx, let me know if anyone can help me
Input File Column headers:
Blue Green Red Blue Red Blue Yellow Green
Expected Resuts:
Blue/1 Green/1 Red/1 Blue/2 Red/2 Blue/3 Yellow/1 Green/2
Thanks
Solved! Go to Solution.
Hi @skotian1289 ,
Alteryx does a kind of "rename" on import adding a count to the header, but the result would not be exactly what you want (e.g. Green, Green1, Green2),
but of course you can add a unique identifier to your headers. I've added a sample workflow, let me know it if works for you.
Best,
Roland
Hi @skotian1289 — Are you looking for this:
Please mark it "Solved" or "Solved" with a Like if it resolved your query. This will help other users find the same answer/resolution. Thank you.
Hi @skotian1289 , alteryx has the capability to rename duplicate fields of its own. Please refer to the screenshots.
Thanks.
Hi Viz Alter,
This is exactly what I was looking for however a small issue, when a column header is repeated for more than 9 times the column name changes to Blue9_/2 or Blue9_/3 . Is it possible similar to excel formula output the name captures Blue/10, Blue/11, Blue/12 , Blue/13 and so on ?
Thanks
Hi @skotian1289 , is this what you are looking for?
If yes, then please mark this post as solution.
Thanks.
@skotian1289 — Try this solution:
Please mark it "Solved" or "Solved" with a Like if it resolved your query. This will help other users find the same answer/resolution. Thank you.
Hi Viz Alter,
A quick question on the solution below, the Regex formula which you have used in your worklflow is not working for few samples like below cases.
Formula used: IF REGEX_Match([Name], "^[^0-9]+$") THEN [Name]+"1" ELSE [Name] ENDIF
REGEX_Replace([Name_new], "(.*)([0-9]+$)", "$1"+"/"+"$2")
Cases where the above formula is changing our headers completely.
1.) Original Header name: User 1 Post Formula header name: User/1 Instead of: User 1/1
2.) Original Header name: User 1 Name Post Formula header name: User 1 Name Instead of: User 1 Name/1
Apologies I am not a pro in regex expression, M I not using the formula correctly ?
Thanks
A quick question on the solution below, the Regex formula which you have used in your worklflow is not working for few samples like below cases.
Formula used: IF REGEX_Match([Name], "^[^0-9]+$") THEN [Name]+"1" ELSE [Name] ENDIF
REGEX_Replace([Name_new], "(.*)([0-9]+$)", "$1"+"/"+"$2")
Cases where the above formula is changing our headers completely.
1.) Original Header name: User 1 Post Formula header name: User/1 Instead of: User 1/1
2.) Original Header name: User 1 Name Post Formula header name: User 1 Name Instead of: User 1 Name/1
Apologies I am not a pro in regex expression, M I not using the formula correctly ?
Thanks
Hi @skotian1289 ,
Can you please try it out.
Input
Output
I feel this will be much more flexible then the regex.
Workflow
Please check and let me know.
Hope this helps : )
Reply back if there is any issues.