<!-- https://learnsql.cpetoday.com/functions/m/table-reordercolumns -->
# Table.ReorderColumns

Language: Power Query M
Category: Table: columns
Syntax: Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table
Summary: Moves the named columns to the front, in the order you list them.
Returns: The table with its columns rearranged. Columns you do not name follow in their current order.
Level: Beginner
Related: Table.SelectColumns, Table.RenameColumns, Table.RemoveColumns, Table.DuplicateColumn

## What it does
Table.ReorderColumns changes the left-to-right order of columns in the table. It does not remove any columns. Use it to put the key fields first, such as account and name, so the table reads well in the editor and in the report.

## Syntax and arguments
- **table**: the table to rearrange. Required.
- **columnOrder**: a list of column names in braces, in the order you want the first columns to appear. Required.
- **missingField**: what to do with a name that does not exist. The default is an error. `MissingField.Ignore` skips missing names.

## Example
A trial balance export has its account number and account name in the middle of the sheet. They are moved to the front.

```powerquery
let
    Source = Excel.CurrentWorkbook(){[Name = "TrialBalance"]}[Content],
    KeyFirst = Table.ReorderColumns(Source, {"Account", "Account Name"})
in
    KeyFirst
```

Account and Account Name become the first two columns. All the other columns follow in their original order.

## Example: a second, different use
After a budget grid is unpivoted, the columns come out in a different order. The reshaped table is arranged as account, month and amount for the budget model.

```powerquery
let
    Source = Excel.CurrentWorkbook(){[Name = "Budget2026"]}[Content],
    Long = Table.UnpivotOtherColumns(Source, {"Account"}, "Month", "Budget"),
    Arranged = Table.ReorderColumns(Long, {"Account", "Month", "Budget"})
in
    Arranged
```

## Things to watch
- This step only moves columns. To drop a column, use Table.RemoveColumns or Table.SelectColumns.
- Column order matters when you build a table from lists with Table.FromRows, because values are matched by position there.
- Table.Combine matches columns by name, so the order of columns in two files does not need to match for combining.
- Query folding: moving columns usually folds, because it only changes the SELECT list. Check View Native Query if it matters.

## In business terms
A consistent column order makes a schedule easier to check by eye and easier to hand to someone else. For a model that loads the table, the order of key fields is a readability choice rather than a calculation.
