Power Query Problems

Transpose Month and Subcategory Data with Power Query

Rana GarciaRana Garcia Dec 2, 2026 868 views

Question details

Convert product data with month columns and subcategory rows into a normalized table, then display subcategories as columns.

Transpose Month and Subcategory Data with Power Query
Product
Microsoft Power Query in Excel or Power BI
Device & OS
not provided
Scenario
Prepare product, month, subcategory, and value data for analysis and reporting.
Observed behavior
The source has months in columns and subcategories in rows; the desired report places subcategories in columns.
Before you start

Check that the source has headers for Product, Subcategory, and each month, with values under the month columns. If the source is in Excel, select the range and choose Insert > Table before opening it in Power Query.

Solution 1Recommended

Unpivot the month columns and create a PivotTable

Use this approach to produce a flat table for analysis and a separate report with subcategories as columns.

1
Open the source in Power Query

In Excel, select a cell in the source table and choose Data > From Table/Range. In Power BI Desktop, choose Home > Transform data and select the source query.

2
Unpivot the months

In Power Query Editor, select the Product and Subcategory columns, then choose Transform > Unpivot Columns > Unpivot Other Columns. The month headers become values in an Attribute column.

3
Name and check the columns

Double-click Attribute and rename it Month. Confirm the resulting columns are Product, Month, Subcategory, and Value, and use the data type icons in the headers to set appropriate types.

4
Load the flat table

In Excel, choose Home > Close & Load. In Power BI Desktop, choose Home > Close & Apply to load the transformed query.

5
Build the report

In Excel, select the loaded table and choose Insert > PivotTable. Place Product and Month in Rows, Subcategory in Columns, and Value in Values. In Power BI, add a Matrix visual and place the same fields in Rows, Columns, and Values.

Unpivot the month columns and create a PivotTable
Check the value calculation: If there are multiple records for a product, month, and subcategory, the PivotTable or matrix will aggregate them. Check the Values settings and choose the calculation that fits your data.
Free Microsoft Office alternative

Analyze Product Tables with WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files to continue working with product tables and PivotTables. WPS does not replace the Power Query transformation described above.

Use PivotTables to summarize product, month, and subcategory dataOpen and edit Microsoft Excel XLSX and XLS filesWork in a familiar, easy-to-use spreadsheet interfaceMove existing compatible spreadsheets into a lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Which columns should I select before unpivoting?

Select Product and Subcategory, then choose Transform > Unpivot Columns > Unpivot Other Columns. This keeps those identifiers while turning the month columns into rows.

Why are my subcategories still in rows after unpivoting?

Unpivoting creates the flat table; it does not place subcategories in columns. Create a PivotTable or Power BI Matrix with Subcategory in Columns, or select Subcategory and use Transform > Pivot Column in Power Query.

What happens if a product has several values for the same month and subcategory?

A PivotTable, matrix, or Power Query pivot can aggregate those values. Choose a suitable calculation, such as Sum, in the Values settings or the Pivot Column dialog.

Can I refresh the output when the source data changes?

Yes. In Excel, use Data > Refresh All. In Power BI Desktop, use Home > Refresh. If you created an Excel PivotTable from the loaded query, refresh it as well.