Unpivot Monthly Columns into a Clean Table with Power Query

Unpivot Monthly Columns into a Clean Table with Power Query

📎 This article includes 1 downloadable practice file ↓

⏱ 2 min readUpdated 27 September 2026

Budgets, SAP exports and Smart View sheets often come “wide”: one row per account and a column for each month. It looks nice, but it is terrible for analysis — you cannot filter by month, pivot tables get awkward and every formula needs twelve ranges. The fix is to unpivot.

In this article
  1. Before and after
  2. Steps
  3. Make months sortable
  4. What you can do now
  5. Try it yourself: step by step

Before and after

Account Jan Feb Mar
Travel 1200 800 950
Rent 5000 5000 5000

becomes

Account Month Amount
Travel Jan 1200
Travel Feb 800
… … …

Steps

  1. Click inside the data and choose Data → From Table/Range (tick “My table has headers”).
  2. In Power Query, select the column(s) that describe the row — here Account.
  3. Transform → Unpivot Columns → Unpivot Other Columns.
  4. Rename Attribute to Month and Value to Amount. Set Amount to Decimal Number.
  5. Close & Load.
💡 Always use Unpivot Other Columns (select the ID columns) rather than selecting the month columns. When next year adds a new month column, the query still works.

Make months sortable

“Apr” sorts before “Jan” alphabetically. Add a custom column that turns the month name into a real date:

= Date.FromText("1 " & [Month] & " 2025")

Change its type to Date and sort by it. Now charts and timelines behave.

What you can do now

  • A pivot table with Month in columns and Account in rows — in seconds.
  • =SUMIFS(Amount, Account, "Travel", Month, "Feb") — one simple formula.
  • Load it to the Data Model and build Power BI-style measures.

Want the reverse — a wide summary from a tidy table? That is exactly what a pivot table (or PIVOTBY in Microsoft 365) does.

Try it yourself: step by step

  1. Download budget-wide.xlsx: 8 accounts, a cost centre column and 12 month columns.
  2. Click any cell in the table → Data → From Table/Range → tick “My table has headers”.
  3. Select Account and Cost Centre (hold Ctrl) → Transform → Unpivot Columns → Unpivot Other Columns.
  4. Rename the columns to Month and Amount; set Amount to Whole Number. The preview shows 96 rows.
  5. Close & Load, then insert a pivot table: Month in Columns, Account in Rows, Amount in Values — you have rebuilt the original view, but now it can be filtered and charted freely.

📎 Practice files for this article

  • 📗
    Wide budget workbook8 accounts u00d7 12 month columns u2014 unpivot it into 96 tidy rows.
    ⬇ XLSX · 6 KB

Free to use for learning. Files with macros (.bas) are plain text — import them with Alt+F11 → File → Import File, and always test on a copy.