Forum Discussion
Conditionally rename columns
- Anonymous5 years ago
All you have to do is use Table.RenameColumns, and add the renames whether or not that table's column names are correct or not, because you can add the MissingField.Ignore parameter. So in your Transform file, after you've promoted headers, or at whatever point your column names are in place, add this as your next step:
= Table.RenameColumns(PriorStepName, {{"Document type", "Document Type"}, {"Amt. in loc. curr.", "Amount In Local Currency"}, {"Another bad name", "Another Bad Name"}}, MissingField.Ignore)
If the column name is incorrect, it'll get corrected. If it's already correct, then the misspelled column is not present in that table, and will be ignored.
--Nate
All you have to do is use Table.RenameColumns, and add the renames whether or not that table's column names are correct or not, because you can add the MissingField.Ignore parameter. So in your Transform file, after you've promoted headers, or at whatever point your column names are in place, add this as your next step:
= Table.RenameColumns(PriorStepName, {{"Document type", "Document Type"}, {"Amt. in loc. curr.", "Amount In Local Currency"}, {"Another bad name", "Another Bad Name"}}, MissingField.Ignore)
If the column name is incorrect, it'll get corrected. If it's already correct, then the misspelled column is not present in that table, and will be ignored.
--Nate