A sales file with one column per month is a cross-tab, not a tidy table: it cannot be filtered by month or summed by month without restructuring. Unpivot turns the month headers into rows, giving one Month column and one value column.
What you need
- Excel with the cross-tab loaded in the Power Query Editor
- A note of which columns identify the row, such as Customer and Product
- A copy of the source file
Step 1: Select the identifier columns
In the Power Query Editor, select the identifier columns you want to keep, such as Customer and Product. Do not select the month columns.
Step 2: Unpivot the other columns
Choose Transform, Unpivot Columns, Unpivot Other Columns. Power Query turns each month header into a row, with the month name in an Attribute column and the amount in a Value column.
Step 3: Rename the new columns and check the row count
Rename Attribute to Month and Value to a meaningful measure name, such as Sales. Check the row count: it should equal the old row count times the number of month columns.
Worked example: synthetic 12-row, three-month sales table
The table below is a synthetic example. It shows the expected result of unpivoting month columns; no file was imported.
| Check | Count | Result |
|---|---|---|
| Rows before unpivoting | 12 | Source |
| Month columns | 3 | Jan, Feb, Mar |
| Rows after unpivoting | 36 | 12 times 3 |
| Total sales after unpivoting | 3,600 | Matches the source total |
Expected result (UNTESTED). 12 rows with 3 month columns become 36 rows with one Month column and one Sales column, and the total of 3,600 matches the source total. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- Unpivot only the month columns; unpivoting an identifier column turns it into data.
- The Attribute column holds the old header text; rename it so readers understand it.
- Pivot is the reverse step, for when one column per category is needed instead.
