Table.ReorderColumns

 

This topic applies to the Power Query Formula Language which can be used with Power Query and Power BI Desktop to build queries that mashup data. See the list of function categories.

Returns a table with specific columns in an order relative to one another, without changing the order of the columns that aren’t specified.

Table.ReorderColumns(table as table, columnOrder as list, optional missingField as nullable number) as table  

ArgumentDescription
tableThe Table to modify.
columnOrderThe list of columns to arrange in the specific order.
optional missingFieldThe default value of missingField is MissingField.Error. For more information, see Parameter Values.
  • Table.ReorderColumns is similar to Record.ReorderFields applied to every row in a table.

  • Columns that are not specified will remain in the same location and the specified columns will be ordered around them.

Table.ReorderColumns(Table.FromRecords({[CustomerID=1, Phone = "123-4567", Name ="Bob"] }), {"Name","Phone"})  

CustomerIDNamePhone
1Bob123-4567
CustomerIDNamePhone
1Bob123-4567
Table.ReorderColumns(Table.FromRecords({  
  
    [CustomerID=1, Name = "Bob", Phone = "123-4567"]  
  
}), {"Address1", "Address2"}, MissingField.UseNull)  
  
Table.ReorderColumns(Table.FromRecords({  
  
    [CustomerID=1, Name = "Bob", Phone = "123-4567"]  
  
}), {"Address1", "Address2"}, MissingField.UseNull)  

CustomerIDNamePhone
ddress1Address2
1Bob123-4567nullnull
Show: