Power Query Problems

Unpivot Excel Data with Two Header Rows in Power Query

Steven ParkerSteven Parker Dec 2, 2026 868 views

Question details

Reshape an Excel data source with two header rows into a structure that supports filtering and visualization.

Unpivot Excel Data with Two Header Rows in Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
A large data source contains month and category information across two header rows, and manual transformation is impractical.
Observed behavior
The desired result is a refreshable table with separate month, category, and value fields for charts and other visuals.
Before you start

Identify the two header rows, the columns that identify each record, and a separator that does not appear in the header text. If the source exceeds an Excel worksheet's row limit, make sure Power Query can connect to the complete source rather than only a worksheet extract.

Solution 1Recommended

Combine the header rows and unpivot in Power Query

Use a refreshable query to turn the two header rows into separate fields without editing individual records.

1
Open the source in Power Query

In Excel, select Data > Get Data and connect to the source, or select Data > From Table/Range for worksheet data. Choose Transform Data if the Navigator appears.

2
Restore the header rows

In Power Query Editor, check that both original header rows appear as data. If the first row was promoted automatically, select Transform > Use Headers as First Row. Remove any automatic Changed Type step in Applied Steps if it interferes with the transformation.

3
Transpose and combine headers

Select Transform > Transpose. If grouped header labels have blank cells beneath them after transposing, select the appropriate header column and choose Transform > Fill > Down. Select the first two columns in the order you want the fields to appear, then choose Transform > Merge Columns and use a separator such as a vertical bar that is absent from the header text.

4
Restore the table layout

Select Transform > Transpose again, then choose Home > Use First Row as Headers. Check that identifier columns and the combined value-column headers are named as expected.

5
Unpivot the value columns

Select the identifier columns that should remain fixed, then choose Transform > Unpivot Columns > Unpivot Other Columns. Power Query creates Attribute and Value columns from the remaining columns.

6
Separate and type the fields

Select the Attribute column and choose Transform > Split Column > By Delimiter using the separator from the merge. Rename the resulting columns for their contents, such as Month and Category, and set the appropriate data types using the column header type icons.

7
Load the result

Select Home > Close & Load To and choose a suitable destination. For a result larger than a worksheet can hold, load it to the Data Model where available, then use it in a PivotTable or chart.

Combine the header rows and unpivot in Power Query
Check the result before loading: Unpivoting can omit null values, so verify whether missing values need to be retained. If different categories contain incompatible value types, keep the Value column untyped until you decide how to handle each category.
Free Microsoft Office alternative

Work with Reshaped Excel Data in WPS Spreadsheet

WPS Office is a free, lightweight Office alternative with a familiar interface and Excel format compatibility. Open a reshaped workbook in WPS Spreadsheet to review, filter, and chart its data while moving between office suites.

Filter and chart reshaped month and category dataOpen and save Microsoft Excel formats, including XLSXUse a familiar spreadsheet interface for an easier transitionWork with a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why should I transpose the table before merging the headers?

Transposing turns the two header rows into columns, allowing you to combine corresponding header values with Transform > Merge Columns. Transpose again to restore the original layout before promoting the combined row.

What if the first header row contains blank cells under grouped labels?

After transposing, select the column containing the grouped labels and use Transform > Fill > Down before merging. Check that the filled labels match the intended groups.

Which columns should I select before unpivoting?

Select the identifier columns you want to keep, such as product or region, and choose Transform > Unpivot Columns > Unpivot Other Columns. The remaining column names become Attribute values.

Can the unpivoted result contain more rows than an Excel worksheet?

Yes. If the result exceeds the worksheet row limit, use Home > Close & Load To and load it to the Data Model where available, rather than to a worksheet.

Will the query run again when the source data changes?

Yes. After loading, use Data > Refresh All in Excel to rerun the query. New columns can be included by Unpivot Other Columns, provided they follow the same header structure.