Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
ArchStanton
Impactful Individual
Impactful Individual

How to batch multiple Renamed Column steps into one step

I've just watched Chandeeps latest video where he talks about 'Batching' and removing unecessary steps for renaming columns.
Unfortynately, he doesn't explain how to do this in the video: Cut Your Power Query Steps in Half (With These Tricks )

 

I have 8 column rename steps that I would like to consolidate if possible, can someone show me how to combine these into one step please?
Here are are the first 3 in my Query:

Renamed Columns

= Table.RenameColumns(#"Filtered Rows1",{{"ticketnumber", "Case Number"}, {"createdon", "Created On"}})

 

Renamed Columns1

= Table.RenameColumns(#"Expanded tpo_PrimaryTopic",{{"pre_resolutiondate", "Resolution Date"}})

 

Renamed Columns2

=Table.RenameColumns(#"Duplicated Column",{{"Created On - Copy", "Created On - Hierarchy"}})

 

Thanks

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

@ArchStanton 

Hi again

In answer to your question "My M code knowledge is very limited, can you provide an example of how this code will look"

You can learn yourself.

 

Simply create some test data

 

speedramps_1-1753271970940.png

Edit the query and overtype the columns.

The Power Query will automatically generate the the M rename code in the top window

speedramps_3-1753272103822.png

If you click Advanced Editor then you can view the whole M script
 

speedramps_5-1753272352114.png

 

 

This is how most developers learn M code,

by first using the wizard to crearte code
and then editing it.

 

Learn more about Power Query for free here 
https://www.youtube.com/watch?v=i66yyAl5_Jc

 

Please click thumbs up and [accept solution] buttons.

 

 

 

 

View solution in original post

5 REPLIES 5
ArchStanton
Impactful Individual
Impactful Individual

Thanks, unfortunately I'm stuck with these multiple steps as the query fails when I remove and try to edit column name changes, this is because in the middle of all of these transformations - I have merged queries and done a whole host of other steps that I have unsuccessfully tried to pick apart and edit but failed.

Thanks for you help anyway

Hi again @ArchStanton 

In repy to your comment "Thanks, unfortunately I'm stuck with these multiple steps as the query fails when I remove and try to edit column name changes, this is because in the middle of all of these transformations - I have merged queries and done a whole host of other steps that I have unsuccessfully tried to pick apart and edit but failed."

 

Please can you kindly click [accept solutoon] because the solution works

 

I have provided you wth the solution, examples and a training video link but it sounds like you have given-up trying to implement it.

 

We all started as novices and had to go through the same excerise of unpicking M code to learn.

 

😀

 

 

 

speedramps
Super User
Super User

@ArchStanton 

Hi again

In answer to your question "My M code knowledge is very limited, can you provide an example of how this code will look"

You can learn yourself.

 

Simply create some test data

 

speedramps_1-1753271970940.png

Edit the query and overtype the columns.

The Power Query will automatically generate the the M rename code in the top window

speedramps_3-1753272103822.png

If you click Advanced Editor then you can view the whole M script
 

speedramps_5-1753272352114.png

 

 

This is how most developers learn M code,

by first using the wizard to crearte code
and then editing it.

 

Learn more about Power Query for free here 
https://www.youtube.com/watch?v=i66yyAl5_Jc

 

Please click thumbs up and [accept solution] buttons.

 

 

 

 

speedramps
Super User
Super User

Hi @ArchStanton 

It is best pratice to group Renames into a single step rather than have the steps spread over a Power Query

 

For example instaed of:-

  • Add column 1
  • Rename column 1
  • Add column 2
  • Rename column 2
  • Add column 3
  • Rename column 3

 

 

You could have :-

  • Add column 1
  • Add column 2
  • Add column 3
  • Rename column 1, 2 and 3

 

In your example, I suggest fisrt you back-up your work before making any changes.

Then delete the Renamed Columns, Renamed Columns1 and Renamed Columns2 steps

and add a new step that renames all three columns.

 

Unfortunately, if you have any references to the new name before new step then they will fail with name not found error, but you can easily edit these to the oldname. Then it work ok.

 

Please click thumbs up because I have tried to help.

Then click [accept solution] if it works.

Thank you 

 

Hi, thanks for the reply.

My M code knowledge is very limited, can you provide an example of how this code will look using the 3 examples I've provided please?
Thanks

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors