Table.DemoteHeaders

Updated on

Table.DemoteHeaders is a Power Query M function that demotes the column headers to the first row of values, replacing them with default column names. The function returns a new table with demoted headers.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Table.DemoteHeaders( table as table ) as table

Description

Table.DemoteHeaders demotes the column headers to the first row of values. It changes column names to “Column1”, “Column2”, etc., moving them to the first row.

Examples

Demote the first row of values in the table.

Table.DemoteHeaders( 
    Table.FromRecords( {
        [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
        [CustomerID = 2, Name = "Jim", Phone = "987-6543"]
    } )
 )

 /* Output: 
Table.FromRecords( {
    [Column1 = "CustomerID", Column2 = "Name", Column3 = "Phone"],
    [Column1 = 1, Column2 = "Bob", Column3 = "123-4567"],
    [Column1 = 2, Column2 = "Jim", Column3 = "987-6543"]
} )
 */ 

Other functions related to Table.DemoteHeaders are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/table-demoteheaders