Learn more about the Alteryx Maveryx Universe recently announced at Inspire 2023!

Alteryx Designer Desktop Discussions

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

Dynamically assign column names based on mapping

The1804
6 - Meteoroid

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: 
InputOutput
ColoursColumn1
AnimalsColumn2
 Column3
Numbers 
NamesColumn4
NamesColumn5

 

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:   
ColoursAnimalsNumbersNames
BlackCatOneJack
BrownDogThreeAnna
BluePigTwoChris
YellowChickenFourTom

 

Output:    
Column1Column2Column3Column4Column5
BlackCat JackJack
BrownDog AnnaAnna
BluePig ChrisChris
YellowChicken TomTom

 

Let me know if above info is sufficient.

Thanks in advance.

2 REPLIES 2
fmvizcaino
17 - Castor
17 - Castor

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.

fmvizcaino_0-1591189542754.png

 

Best,

Fernando Vizcaino

 

The1804
6 - Meteoroid

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.

Labels