Record.ReorderFields

Record

Returns a new record with fields reordered according to the specified list. Fields not in the list follow after in their original order.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Record.ReorderFields(record as record, fieldOrder as list, optional missingField as nullable number) as record

Parameters

NameTypeRequiredDescription
recordrecordYesThe source record.
fieldOrderlistYesA list of field name text values specifying the desired order.
missingFieldnumberNoControls behavior when a specified field does not exist: MissingField.Error (default), MissingField.Ignore, or MissingField.UseNull.

Return Value

recordA new record with fields in the specified order.

Remarks

Record.ReorderFields returns a new record with fields placed in the order specified by fieldOrder. Fields not listed in fieldOrder are appended at the end, maintaining their original relative order from the source record. Field names and values are unchanged.

Record field order matters in Power Query because it affects the column order when records are expanded into table columns, and the order in which fields appear in Record.ToTable output. Record.ReorderFields is the record-level equivalent of Table.ReorderColumns.

The optional missingField parameter controls behavior when a name in fieldOrder does not exist in the record: - MissingField.Error (default, 0) — raises an error - MissingField.Ignore (1) — skips missing names silently - MissingField.UseNull (2) — inserts the specified field with a null value

A common pattern is to reorder fields before converting a record to a table with Record.ToTable or before using Table.FromRecords, to control the column order of the resulting table.

Examples

Example 1: Reorder all fields explicitly

Record.ReorderFields(
    [City = "New York", Name = "Alice", Age = 30],
    {"Name", "Age", "City"}
)
Result
Name
Age
City
1Alice30New York

Example 2: Unlisted fields are appended at the end in original order

Record.ReorderFields(
    [D = 4, A = 1, C = 3, B = 2],
    {"A", "B"}
)
Result
A
B
D
C
11243

Example 3: Reorder a Sales row to put OrderID and CustomerName first

let
    Row = Sales{0},
    Reordered = Record.ReorderFields(Row, {"OrderID", "CustomerName", "Product"})
in
    Record.ToTable(Reordered)
Applied Steps

The final output — converts the reordered record to a two-column Name/Value table showing the new field order.

Name
Value
1OrderID1
2CustomerNameAlice
3ProductWidget A
4CategoryWidgets
5UnitPrice25
6Quantity4
7OrderDate2024-01-15
8RegionEast

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks