Unpivot Excel Data with Two Header Rows in Power Query
Question details
Reshape an Excel data source with two header rows into a structure that supports filtering and visualization.

- 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.

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.

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.




