Forum Discussion
How can I replace table column names before expanding data from multiple tables in a folder?
- 7 years ago
No problem, this should look like so then:
Table.TransformColumns(<PreviousStepName>, {{"Data", each Table.RenameColumns(_, Table.ToRows(Mappings), MissingField.Ignore)}})
Hi
just replace <PreviousStepName> by the name of your previous step:
Table.TransformColumns(<PreviousStepName>, {{"Data", each Table.RenameColumns(_,{{"Name", "Customer"}}, MissingField.Ignore)}})
MissingField.Ignore make sure that no error is thrown when the column "Name" doesn't exist in any of the tables. Also you can add more rename pair-lists if needed.
ImkeF ,
Wow. That is so very close (and really helpful). The only thing I need to do is change the {"Name","Customer"} block so the results are pulled from a separate table similar to a lookup.
In my example, I have a separate table called Mappings that is configured as follows:
Column Corrected
Name Customer
Location Office
Is it possible to configure the code so that it checks the corresponding table for each column header and then renames if it finds a match?
Thank you again for your help.
- ImkeF7 years agoCommunity Champion
No problem, this should look like so then:
Table.TransformColumns(<PreviousStepName>, {{"Data", each Table.RenameColumns(_, Table.ToRows(Mappings), MissingField.Ignore)}})- Anonymous5 years agoNot applicable
Can i follow up with this question? I have the samiliar issue. The original data comes with different 2nd column name "XXkisngihudg" but it is the same column saying "FileIDs". How to handle this issue?
My data looks like this. PowerBi reads in using Row2 as default header. Can I use row 1 as default header, like "Column1", "Column2","Column3",.... This dynamic FileIDs gave me a headache to merge different data files.
Thanks!