Table.ReorderColumns Function in Power Query
The Table.ReorderColumns function returns a table with specific columns in an order relative to one another.
Syntax
Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table
Example:
Power Query M
let
MyTable = Table.FromRecords(
{
[CustomerID = 1, Name = "Ashish", Marks = 568],
[CustomerID = 2, Name = "Katrina", Marks = 855],
[CustomerID = 3, Name = "Alia", Marks = 380],
[CustomerID = 4, Name = "Vicky", Marks = 458],
[CustomerID = 5, Name = "Mohini", Marks = 278],
[CustomerID = 6, Name = "Meenakshi", Marks = 289],
[CustomerID = 7, Name = "Esha", Marks = 875],
[CustomerID = 8, Name = "Anjali", Marks = 380]
}
),
return = Table.ReorderColumns(MyTable, {"Marks", "Name"})
in
return The output of the above code is shown below:

Example: Use the third parameter in the function, MissingField.UseNull.
Power Query M
let
MyTable = Table.FromRecords(
{
[CustomerID = 1, Name = "Ashish", Marks = 568],
[CustomerID = 2, Name = "Katrina", Marks = 855],
[CustomerID = 3, Name = "Alia", Marks = 380],
[CustomerID = 4, Name = "Vicky", Marks = 458],
[CustomerID = 5, Name = "Mohini", Marks = 278],
[CustomerID = 6, Name = "Meenakshi", Marks = 289],
[CustomerID = 7, Name = "Esha", Marks = 875],
[CustomerID = 8, Name = "Anjali", Marks = 380]
}
),
return = Table.ReorderColumns(MyTable, {"Marks", "Name", "Status"}, MissingField.UseNull)
in
return The output of the above code is shown below:
