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.
- dehmos277 years agoFrequent Visitor
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)}})