How to Unpivot Columns in Power Query

Many spreadsheets are designed for easy human reading, with months, quarters, or regions spread across multiple columns. While this wide format looks clean, it breaks when you try to build a Pivot Table, create dynamic summaries, or run automated reports.The solution is to unpivot your data using Power Query. Unpivoting transforms column headers into attribute rows, turning a wide cross-tab table into a clean, structured dataset ready for analysis.

Sample Data Before Unpivoting

Suppose you have a monthly sales report formatted like the table below in cells A1:D4:

Product Jan Feb Mar
Laptop 1200 1500 1350
Monitor 800 950 1100
Keyboard 450 500 620

Our goal is to keep the Product column intact and turn Jan, Feb, and Mar into two vertical columns: Month and Sales.

Step-by-Step: How to Unpivot Columns in Excel Power Query

  1. Step 1: Load Your Data into Power Query

    Click any cell inside your data table. Go to the Data tab on the Excel ribbon and click From Table/Range in the Get & Transform Data group. If your data is not yet formatted as an official Excel Table, Excel will prompt you to create one. Make sure My table has headers is checked, then click OK.

  2. Step 2: Select the Static Columns

    Once the Power Query Editor opens, click the header of the column you want to keep unchanged. In our example, click the Product column header. If you have multiple identifier columns (such as Region and Product), hold down Ctrl and click each column header.

  3. Step 3: Choose “Unpivot Other Columns”

    Navigate to the Transform tab in the Power Query Editor. Click the small drop-down arrow next to Unpivot Columns and select Unpivot Other Columns.

    Why use “Unpivot Other Columns” instead of “Unpivot Columns”? When you add new columns later (such as Apr or May) and refresh the query, Power Query will automatically unpivot the new months without requiring you to edit your query steps.

  4. Step 4: Rename the Generated Columns

    Power Query creates two new columns named Attribute and Value. Double-click the Attribute header, type Month, and press Enter. Double-click the Value header, type Sales, and press Enter.

  5. Step 5: Verify Data Types

    Check the icon next to each column header to ensure the formatting is accurate. Set Product and Month to Text and Sales to Whole Number or Currency. For a deeper walkthrough, see our guide on how to transform data types in Power Query.

  6. Step 6: Close and Load Back to Excel

    Go to the Home tab and click Close & Load. Excel will insert a new worksheet containing your unpivoted, analysis-ready table.

Result After Unpivoting

Your output table will now look like this (showing the first five rows):

Product Month Sales
Laptop Jan 1200
Laptop Feb 1500
Laptop Mar 1350
Monitor Jan 800
Monitor Feb 950

Common Pitfalls to Avoid

  • Leaving Grand Total columns in the source table: If your source table includes a “Total” column on the right, remove it in Power Query before unpivoting. Otherwise, your totals will be mixed into your monthly sales rows and double-counted in Pivot Tables.
  • Empty cells disappearing: By default, Power Query skips null values when unpivoting. If you need to keep rows with zero sales, select the numeric columns and replace null values with 0 before running the unpivot step.
  • Forgetting to refresh: Whenever you add new rows or new month columns to the original table, right-click the output table and select Refresh, or follow our guide on how to refresh Power Query data automatically.
See also  How to Use Exponents in Excel - Complete Guide with Examples