Transpose Month and Subcategory Data with Power Query
Question details
Convert product data with month columns and subcategory rows into a normalized table, then display subcategories as columns.

- 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.
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.
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.
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.
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.
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.
In Excel, choose Home > Close & Load. In Power BI Desktop, choose Home > Close & Apply to load the transformed query.
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.

Pivot subcategories directly in Power Query
Use this option when you want the query output itself to have one column per subcategory.
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.

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.




