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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
dhodgman
Regular Visitor

Feature Request - Single command to do what Table.RenameColumns and Table.ReorderColumns do

I am sooo tired of repeating the pattern of renaming and reordering columns in M query result sets, and then mucking around when I decided that the names need to be different from what I originally picked which then breaks the subsequent reordering.

 

I'd like to see a single command, let's call it Table.RenameAndReorder that does both at once.  The renaming is obvious.  The reordering is done based on the sequence of the renaming pairs that are provided.

 

Related to that, it would be great if the advanced editor put a carriage return between each pair of columns within those commands.

 

This would save much time and frustration.

1 ACCEPTED SOLUTION

I've taken your suggestion and developed a custom ArrangeTableColumns function that allows me to set the desired names, order, and datatypes for all of the columns in a single call.  This allows me to modify any of those settings in one place without breaking subsequent lines of code.  So, objective achieved!  Thanks for that!


The problem is... this custom function is not wired into the lovely Power Query UI so it can't be generated automatically.  Writing the function call in the first place is quite a chore.  So, I created a custom function that generates the call for me based on a specified input table.  A bit clunky but it works if you use it at the right time.

 

I would still love to see a feature added to Power Query that allows us to rename, reorder, and retype all at once; and then change any of those settings without breaking subsequent lines of code.

View solution in original post

11 REPLIES 11
v-tsaipranay
Community Support
Community Support

Hi @dhodgman ,

 

Could you please confirm if you've submitted this as an idea in the Ideas Forum? If so, sharing the link here would be helpful for other community members who may have similar feedback.

If we don’t hear back, we’ll go ahead and close this thread. For any further discussions or questions, please start a new thread in the Microsoft Fabric Community Forum  we’ll be happy to assist.

 

Thank you for being part of the Microsoft Fabric Community.

v-tsaipranay
Community Support
Community Support

Hi @dhodgman ,

Thanks for reaching out to the Microsoft fabric community forum.

 

Currently, there isn't a single native command in Power Query (M) that combines both Table.RenameColumns and Table.ReorderColumns. However, I understand your frustration, and I would like to suggest the following approach:

 

  • You could create a custom Power Query function to handle both renaming and reordering in one step. The function would take the column name pairs for renaming and reorder the columns based on their new names in the provided sequence. While this isn’t built into Power Query natively, a custom function can streamline the process for you.

Please refer to the below link for more information:

Table.RenameColumns - PowerQuery M | Microsoft Learn

Table.ReorderColumns - PowerQuery M | Microsoft Learn

 

Below link will helps to navigate the steps for custom function:

https://support.microsoft.com/en-us/office/create-and-invoke-a-custom-function-5dcedf5f-45a5-4dd7-b8...

 

  • As @Ritaf1983 , if you're working with a database like SQL Server or Azure SQL, you can rename and reorder the columns in the SQL query itself. This is the most efficient way when dealing with database sources.

I hope my suggestions give you good ideas, if you have any more questions or need further assistance, feel free to let me know.

 

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

Thank you.

Hi @dhodgman 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

I've taken your suggestion and developed a custom ArrangeTableColumns function that allows me to set the desired names, order, and datatypes for all of the columns in a single call.  This allows me to modify any of those settings in one place without breaking subsequent lines of code.  So, objective achieved!  Thanks for that!


The problem is... this custom function is not wired into the lovely Power Query UI so it can't be generated automatically.  Writing the function call in the first place is quite a chore.  So, I created a custom function that generates the call for me based on a specified input table.  A bit clunky but it works if you use it at the right time.

 

I would still love to see a feature added to Power Query that allows us to rename, reorder, and retype all at once; and then change any of those settings without breaking subsequent lines of code.

Hi @dhodgman,

 

I'm glad to hear that you've successfully created a custom ArrangeTableColumns function to rename, reorder, and retype columns in one call. While it isn't integrated into the Power Query UI, your workaround is a great solution for now.

I understand your desire for a built-in feature to simplify this process further. Hopefully,Microsoft will consider adding this functionality in the future.

 

In below link add your idea or suggestion to microsoft:
Home

If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

Thank you.

 

 

Hi @dhodgman 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.


Thank you.

Hi @dhodgman ,

 

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

Hi @dhodgman,

 

I wanted to follow up on our previous suggestions regarding Feature Request.

If my response has addressed your query, please accept it as a solution and give a ‘Kudos’ so other members can easily find it. Please let us know if there’s anything else we can do to help.

 

Thank you.

Ritaf1983
Super User
Super User

Hi @dhodgman 

If you're using a source like SQL Server, you can rename and reorder the columns directly in the SQL query before loading the data into Power Query. This approach avoids the need to use both Table.RenameColumns and Table.ReorderColumns later.

For example, you can write:

sql
Copy code
SELECT
Column1 AS NewName1,
Column3 AS NewName3,
Column2 AS NewName2
FROM YourTable;

Ritaf1983_0-1734494337722.png

 


This query renames the columns and defines their order simultaneously, so the data arrives in Power Query exactly as you need it.

That said, if you’d like a combined Table.RenameAndReorder function in Power Query, I recommend submitting it as an Idea in the Power BI Ideas forum, where Microsoft reviews suggestions for future improvements , here is a link :
https://ideas.fabric.microsoft.com/

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Correction... turns out I can't access the ideas forum in my current work situation.  
Perhaps someone can cross post it if you think it's a worthwhile suggestion.

Thanks for your response @Ritaf1983.  Your suggestion is appropriate when pulling a result set from any database.  In my current gig, I'm having to pull data from a cube 😞 which is not so simple to work with.  And thanks for the link to the ideas forum.  I will cross post there.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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