This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Hi,
As the title says. I am trying to change column headers to a different value based on a mapping file. The issue is that the mapping constantly changes so my current solution of manual rename is not sufficient. Additionally the columns are not always 1:1 (ex. Change from column A to Column B) but sometimes they need to be repeated (Column A feeds to Column B and C) or display empty values (no mapping).
Is there an easy solution or an already existing tool which would help me with this problem?
Below I am attaching an example.
Mapping: | |
Input | Output |
Colours | Column1 |
Animals | Column2 |
Column3 | |
Numbers | |
Names | Column4 |
Names | Column5 |
Colours and Animals should be renamed to Column1 and Column2 respectively.
Column3 should be displayed as empty as it has no corresponding value in Input
Numbers should be skipped as it does not exist in Output
Names should be displayed in both Column4 and Column5
n:1 will never happen
Input: | |||
Colours | Animals | Numbers | Names |
Black | Cat | One | Jack |
Brown | Dog | Three | Anna |
Blue | Pig | Two | Chris |
Yellow | Chicken | Four | Tom |
Output: | ||||
Column1 | Column2 | Column3 | Column4 | Column5 |
Black | Cat | Jack | Jack | |
Brown | Dog | Anna | Anna | |
Blue | Pig | Chris | Chris | |
Yellow | Chicken | Tom | Tom |
Let me know if above info is sufficient.
Thanks in advance.
Hi @The1804 ,
For changing column header names, I would normally use the dynamic rename tool to do it.
https://help.alteryx.com/2020.1/DynamicRename.htm
But since your problem involves also the duplication of a column, I needed to use a cross-tab/transpose method along side a join tool to accomplish that.
Best,
Fernando Vizcaino
Hi,
Thank you for quick response.
Your solution is quite close to what I am looking for however I also need the "Template" to be generated based on values in Output column instead of having it fixed manually. Would that be possible to do?
Thanks in advance.