New Tool Radar

AI for Data & Spreadsheets

How to Unpivot Monthly Columns into Rows with Power Query in Excel

Unpivot monthly columns into rows with Power Query so a wide sales table becomes a tall table ready for charts.

Schematic illustration for How to Unpivot Monthly Columns into Rows with Power Query in Excel: three numbered steps - From Table/Range; Select month columns; Unpivot Columns.

A table with one column per month is easy to read and hard to chart, because a chart needs the month in a column of its own. Power Query unpivots the month columns into rows, turning a wide table into a tall one with Month and Value columns that a PivotTable or chart can use directly.

Prerequisites

  • Excel with Power Query
  • A wide table with one column per month
  • A copy of the source file, so the original stays untouched.

Steps

  1. Select the table and go to Data, From Table/Range to open it in the Power Query Editor.
  2. Select the month columns together, then go to Transform, Unpivot Columns.
  3. Rename the two new columns to Month and Value, and set Value to Decimal Number type.
  4. Check the row count: it should equal the number of products times the number of months.
  5. Click Close and Load, then build a PivotTable on the tall table to confirm it charts correctly.

Worked example: Fictional quarterly sales unpivoted

The practice table below is a fictional unpivoted sales list: three products over two months. The amount column is the sales value, and the total is their sum. The table below is fictional practice material, with fictional values. It is the expected result, worked out by hand, not a run of any tool.

Product Month Amount
Novels October 420.00
Novels November 385.50
Cookbooks October 310.25
Cookbooks November 295.75
Poetry October 150.00
Poetry November 142.50
Total 1704.00

Expected result. Six rows, one per product and month, and the amounts add to 1704.00.

Limits

  • Unpivoting does not change the source data, so the wide table stays as it was.
  • A column that is not a month, such as a total column, must not be selected for unpivoting.

Sources

See all