Promote or demote column headers

When you create a new query from unstructured data sources such as text files, Power Query analyzes the contents of the file. If Power Query identifies a different pattern for the first row, it tries to promote the first row of data to be the column headings for your table. However, Power Query might not identify the pattern correctly 100 percent of the time, so this article explains how you can manually promote or demote column headers from rows.

To promote rows to column headers

In the following example, Power Query wasn't able to determine the column headers for the table because the table contains a set of header rows for the first three rows. The actual column headers for the table are contained in row 5.

Initial sample table for promote rows to column headers.

Screenshot of the table with the columns (Column1, Column2, Column3 and Column4) all set to the Text data type, with four rows containing a header at the top, a column header in row 5, and 7 data rows at the bottom.

Before you can promote the headers, you need to remove the first four rows of the table. To make that happen, select the table menu in the upper-left corner of the preview window, and then select Remove top rows.

Screenshot of the table menu with the Remove top rows option emphasized.

In the Remove top rows window, enter 4 in the Number of rows box.

Screenshot of the Remove top rows dialog, with the number of rows set to 4.

Note

To learn more about Remove top rows and other table operations, go to Filter by row position.

The result of that operation leaves the headers as the first row of your table.

Screenshot of the sample table with the column headers in the first row, then seven rows of data.

Locations of the promote headers operation

From here, you have a few places where you can select the promote headers operation:

  • On the Home tab, in the Transform group.

    Screenshot of the Power Query ribbon with the Promote headers button on the Home tab emphasized.

  • On the Transform tab, in the Table group.

    Screenshot of the Power Query ribbon with the Promote headers button on the Transform tab emphasized.

  • On the table menu.

    Screenshot of the Promote headers button on the shortcut menu.

After you do the promote headers operation, your table looks like the following image.

Final table with the promote headers operation.

Table with Date, Country, Total Units, and Total Revenue column headers, and seven rows of data. The Date column header has a Date data type, the Country column header has a Text data type, the Total Units column header has a Whole number data type, and the Total Revenue column header has a Decimal number data type.

Note

Table column names must be unique. If the row you want to promote to a header row contains multiple instances of the same text string, Power Query disambiguates the column headings by adding a numeric suffix preceded by a dot to every text string that isn't unique.

To demote column headers to rows

In the following example, the column headers are incorrect; they're actually part of the table's data. You need to demote the headers to be part of the rows of the table.

Screenshot of the table with part of the data currently used as the column headers.

Locations of the demote headers operation

You have a couple of places where you can select the demote headers operation:

  • On the Home tab, in the Transform group.

    Screenshot of the Power Query ribbon with the Demote headers button on the Home tab emphasized.

  • On the Transform tab, in the Table group.

    Screenshot of the Demote headers option on the Transform tab.

After you do this operation, your table looks like the following image.

Screenshot of the table after demoting headers to rows, with the column headers now set to Column1, Column2, Column3, and Column4.

As a last step, select each column and type a new name for it. The end result resembles the following image.

Final table after renaming column headers.

Filter by row position