Record.ReorderFields

Returns a modified record with the fields reordered based on the specified list called fieldOrder. The values of the fields remain the same, and any fields not included in the fieldOrder list will ret...

Syntax

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

About

Returns a modified record with the fields reordered based on the specified list called fieldOrder. The values of the fields remain the same, and any fields not included in the fieldOrder list will retain their original position in the record.

Explanation

Change the order of certain fields in the record using Power Query function MRecord.ReorderFields. For example, if we have a record with CustomerID, OrderID, Item, and Price fields, we can reorder the fields to have OrderID first and CustomerID second. Before reordering: [CustomerID = 1, OrderID = 1, Item = "Fishing rod", Price = 100.0] After reordering: [OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]