I was working on a dataset where I wanted to change multiple column names using one step and not having to change them manually. Since there were over 30 columns this would be really time consuming.
Below I detail how to complete this in the Power Query Editor, which will replace all the column names for me in one step.
This once again shows how powerful the Power Query Editor can be for ETL and automation tasks!
This is what the Original Column names looked like
To get this working, I had to go into the Advanced Editor and manually add a step.
Here is the Syntax that I added with my Step Name
#”Rename Column Names” = Table.TransformColumnNames(#”Changed Type”, (columnName as text) as text => Text.Replace(columnName, “Sales – “, “”))
- As you can see above my previous step name was called #”Changed Type”
Then the only other change I had to make was for the Text.Replace and what I was searching for and what I wanted to replace it with.
With this example I was looking for “Sales – “, “”
- As you can see I searched for Sales – and replaced with “” (which is blank).
And this is what it looked like after manually adding in the above step.
As I have shown above a quick and easy way to rename multiple columns at once.
You can find the sample file here: Renaming Multiple Columns.pbix
As with every blog post if there are any comments or suggestions please leave them in the section below.