The Table.ReorderColumns function in Power Query changes the order of the columns in a table. You give it the column names in the order you want, and it returns the same table with those columns rearranged.
In this article, I’ll show you how to use it with practical examples, including swapping two columns, moving a column to the front, adding a missing column, and sorting columns A to Z.
Follow along with the example file
Table.ReorderColumns Function Examples.xlsx
Table.ReorderColumns Function Syntax
= Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table
- table – the table whose columns you want to rearrange. This is usually the previous step, such as
Source. - columnOrder – a list of column names in the order you want them, such as
{"Customer","Amount"}. It has to be a list in curly brackets, even for one column, and the names are case-sensitive. - missingField (optional) – what to do when a column in your list doesn’t exist in the table. By default (
MissingField.Error), you get an error.MissingField.Ignoreskips the missing column, andMissingField.UseNulladds it as a new column filled with null.
What it returns – the same table with the listed columns in the new order. All the rows and values stay as they are.
Keep one thing in mind before the examples. The columns you list only trade places with each other, and any column you leave out of the list stays exactly where it was.
The Table.ReorderColumns function works in Power Query in Excel for Microsoft 365, 2024, 2021, 2019, 2016, and Excel for Mac (Microsoft 365), as well as in Power BI.
When to Use the Table.ReorderColumns Function
Use this function when you need to:
- Swap two columns that are in the wrong order
- Set the full column order of a table before you load it to a sheet
- Move a column to the front or the end without typing every column name
- Make files from different sources follow the same column layout
- Add a column that some files are missing, so every file has the same columns
- Sort the columns of a table alphabetically
Example 1: Swap Two Columns
Let’s start with the simplest use, swapping two columns that sit next to each other.
Below is a list of volunteer shifts with the shift ID, hours, volunteer name, and event, and I want the Volunteer column to come before the Hours column.

To follow along, select any cell in the table and go to Data > From Table/Range to open it in the Power Query Editor. If Power Query adds a Changed Type step, use #"Changed Type" in place of Source in the formulas below.
Add a new step (by clicking on the fx icon next to the formula bar) and use this formula:
= Table.ReorderColumns(Source,{"Volunteer","Hours"})
Result: a table with the columns in the order Shift ID, Volunteer, Hours, Event

Here, the list has the two column names in the order I want them, Volunteer first and then Hours. The two columns swap places, and Shift ID and Event stay where they were.
Notice that I only listed the two columns I wanted to move. You don’t have to list every column, as long as the columns you list are the ones that need to change places.
Example 2: Set the Order of All the Columns
When a table needs a completely new layout, list every column in the order you want.
Below is a car rental booking list where the booking number and customer name are at the end, and I want the columns in the order Booking No, Customer, Pickup City, Car Model, Days.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.ReorderColumns(Source,{"Booking No","Customer","Pickup City","Car Model","Days"})
Result: a table with the columns in the order Booking No, Customer, Pickup City, Car Model, Days

Here, all five columns are in the list, so the table follows the list exactly. Each name can appear only once, though, and listing the same column twice gives the error “The field ‘Customer’ already exists in the record.”
The Table.SelectColumns function also returns columns in the order you list them, but it removes every column you leave out. Table.ReorderColumns never removes a column, so it’s the safer choice when you only want to change the order.
Example 3: Swap Two Columns That Aren’t Next to Each Other
This one shows how the function treats the columns you don’t list.
Below is a conference schedule where End Time comes before Start Time, with the Room column between them, and I want Start Time to come before End Time.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.ReorderColumns(Source,{"Start Time","End Time"})
Result: a table with the columns in the order Session, Start Time, Room, End Time, Speaker

Here, End Time was in the second position and Start Time in the fourth. Table.ReorderColumns puts the listed columns back into those same two positions, in the order of the list, so Start Time takes the second position and End Time the fourth.
Room isn’t in the list, so it stays in the third position, between the two times. That’s how this function always works, and it’s the reason the next example needs a little more than a short list.
Example 4: Move a Column to the Front
A very common need is to bring one column to the start of the table.
Below is a warehouse pick list where the Picker column is the last one, and I want to move it to the front.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon).
You might expect this formula to do it, since it lists Picker first and Item (the current first column) second:
= Table.ReorderColumns(Source,{"Picker","Item"})
Result: a table with the columns in the order Picker, Bin, Qty, Order Ref, Item

Picker does move to the front, but Item ends up at the end. That’s because the two listed columns only trade places, the same way Start Time and End Time did in Example 3.
To move Picker to the front and keep every other column in its current order, replace the formula in that step with this one:
= Table.ReorderColumns(Source,{"Picker"}&List.RemoveItems(Table.ColumnNames(Source),{"Picker"}))
Result: a table with the columns in the order Picker, Item, Bin, Qty, Order Ref

Here, the Table.ColumnNames function gives the list of all the column names, and the List.RemoveItems function takes Picker out of that list. Then {"Picker"}& puts Picker at the start, which gives {"Picker","Item","Bin","Qty","Order Ref"}.
Since that list has every column, the table follows it exactly. And because the formula reads the column names from the table, it still works if the table gains or loses a column later.
Example 5: Move a Column to the End
This next one works the same way, but from the other end of the table.
Below is a list of expense claims where the Notes column is second, and I want to move it to the end so the claim details are together.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.ReorderColumns(Source,List.RemoveItems(Table.ColumnNames(Source),{"Notes"})&{"Notes"})
Result: a table with the columns in the order Claim No, Employee, Category, Amount, Notes

Here, the List.RemoveItems function takes Notes out of the list of column names, and &{"Notes"} adds it back at the end. The other four columns keep their order.
Example 6: Reorder Columns When One Might Not Exist (MissingField.Ignore)
By default, Table.ReorderColumns gives an error when a column in your list isn’t in the table. The third argument lets you change that.
Below is a weekly class attendance export, and I want the columns in the order Session, Class, Student, Status, Remarks. Some weeks’ exports have a Remarks column, but this one doesn’t.

If you use Table.ReorderColumns(Source,{"Session","Class","Student","Status","Remarks"}) here, the step fails with this message: “Expression.Error: The column ‘Remarks’ of the table wasn’t found.”
You get the same error when the capitalization doesn’t match. Asking for “session” when the column is “Session” fails too.
Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.ReorderColumns(Source,{"Session","Class","Student","Status","Remarks"},MissingField.Ignore)
Result: a table with the columns in the order Session, Class, Student, Status

Here, MissingField.Ignore tells the function to skip any column it can’t find. The four columns that exist follow the list, and Remarks is skipped without an error.
When a week’s export does have the Remarks column, the same query puts it at the end. Just remember that Ignore also hides typos, so if a column doesn’t move, check its spelling in the list.
Example 7: Add a Missing Column While Reordering (MissingField.UseNull)
Sometimes you want every file to end up with the same columns, even when one of them is missing.
Below is the October sales export from one region, which has no Returns column. The other regions’ files have Region, Rep, Units, Returns, and Revenue, and I want this one to match.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.ReorderColumns(Source,{"Region","Rep","Units","Returns","Revenue"},MissingField.UseNull)
Result: a table with the columns in the order Region, Rep, Units, Returns, Revenue, where every Returns value is null

Here, MissingField.UseNull adds the Returns column, fills it with null, and places it where the list says. The other columns also follow the list, so Region now comes before Rep.
Now this file has the same five columns, in the same order, as the other regions’ files. So anything built on that layout, like a report sheet or a later step that refers to the Returns column, works on this file too.
Important: Use UseNull with a list that has every column, like in this example. With a shorter list, the new column can end up in an unexpected place, sometimes at the end and sometimes pushing one of the listed columns to the end.
Follow along with the example file
Table.ReorderColumns Function Examples.xlsx
Example 8: Sort Columns Alphabetically
This last one is handy when a table has many columns with similar data, like products or regions, and you want them in a predictable order.
Below is a bakery sales table with the store in the first column and one column for each product, and I want the product columns sorted A to Z, with Store still first.

Load this table into Power Query the same way as in Example 1, then add a new step (by clicking on the fx icon) and use this formula:
= Table.ReorderColumns(Source,List.Sort(List.Skip(Table.ColumnNames(Source),1)))
Result: a table with the columns in the order Store, Bagels, Croissants, Muffins, Scones

Here, the Table.ColumnNames function gives all the column names, and the List.Skip function leaves out the first one, Store. The List.Sort function then sorts the product names A to Z.
Store isn’t in that list, so it stays in the first position, just like the unlisted columns in Example 3. The four product columns are rearranged among their own positions in sorted order.
This relies on Store being the first column, though. If a new export ever puts another column first, that column stays in place and Store gets sorted in with the product names.
If a new product column is added later, it’s sorted into place on the next refresh. To sort every column, Store included, drop the List.Skip part and use = Table.ReorderColumns(Source,List.Sort(Table.ColumnNames(Source))) instead.
Other Excel Articles You May Also Like:
- Table.ColumnNames – Use Table.ColumnNames in Power Query M to list a table’s column names.
- Table.RemoveColumns – Use Table.RemoveColumns in Power Query M to delete columns.
- Table.Sort – Use Table.Sort in Power Query M to reorder table rows alphabetically, by number, or by date.
- Table.RenameColumns – Guide to Table.RenameColumns in Power Query M.
- List.Reverse – Use List.Reverse in Power Query M to reverse the order of a list.
- Table.UnpivotOtherColumns – Use Table.UnpivotOtherColumns in Power Query M to turn columns into rows.
- Table.ReverseRows – Use Table.ReverseRows in Power Query M to flip row order.
- Table.Unpivot – Use Table.Unpivot in Power Query M to turn columns into rows.