Every month my input column header for two of the columns change. For example: In Nov-2021, below would be my column headers:
Description | Period 11 Actual 2021 | Cumulative 11 Actual 2021 |
x | 1000 | 5120 |
y | 2000 | 6000 |
z | 3000 | 5000 |
In Dec-2021, below would be my column headers:
Description | Period 12 Actual 2021 | Cumulative 12 Actual 2021 |
x | 1000 | 6210 |
y | 2000 | 8000 |
z | 3000 | 8000 |
I want to rename 2nd and 3rd column headers as 'Actual Amount' and 'Cumulative Amount', respectively. How can I do this?
Hi @aishwarya_baburaj98 ,
There are many ways that you can make this happen, which one is best is another story as it depends on your actual data.
Given the provided data table though and assuming that your headers always come in in this format "Period (month) Actual (year)" or "Cumulative (month) Actual (year)", you can use a dynamic rename tool with a Regex match function to rename your fields dynamically.
Another way would be to use a contains function, to look for the words "period" and "actual" within a header, and replace it with "actual amount", but this will rename all headers that may contain both those words, so look out for that.
You can try changing the month and year in your input and you will notice that still your columns get renamed. This method is not going work if you have data for two months for example in the same table, i.e. if you had both November and December data in your input, as Alteryx will assign the same header to all months, and since you can't have columns with the same headers, the second one will be renamed to "Actual Amount2".
Hope this helps,
Angelos
If it's always the 2nd and 3rd column that you want to rename you can use this technique that uses the order of the fields with no regard for the names.
The Field Info tool returns the names of the fields and their sizes and types as a set of rows. Add a FieldOrder to this and explicitly rename the 2nd and 3rd columns
Dan