Many reports arrive as a neat grid. Regions run down the side, and months spread across the top. It reads beautifully on paper, so people love it. Yet the moment you try to analyse it, everything jams. A PivotTable cannot read months that live in twelve separate columns. The fix is unpivot, and Power Query makes it a two-click job that flattens any cross-tab into clean, tabular data.
This guide shows how to convert cross-tabs the right way. First, it explains why cross-tabs block analysis. Then it covers unpivot, the robust method, and a real example. Renaming, typing, and a full troubleshooting section follow. By the end, you will flatten any matrix in seconds.
The Cross-Tab Problem
A cross-tab spreads one field across many columns. Months, quarters, or products each get a column. That layout is easy for a human to scan. However, it is the wrong shape for analysis, as below.
Analysis tools expect one column per field. They want a single Month column, not twelve. So a cross-tab must be reshaped first. Tabular data, by contrast, pivots and filters with ease.
What Unpivot Does
Unpivot rotates columns into rows. Each old header becomes a value in a new column. The number underneath moves into a Value column. As a result, wide data becomes long and tidy, as below.
How to Unpivot Columns
The basic move takes only a moment. You select the columns you want to rotate. Then one command flattens them into rows. So a wide block collapses into two clean columns.
Use Unpivot Other Columns
There is a smarter, safer version of this. Instead of picking the month columns, pick what to keep. You select only the columns to hold still, like Region. Then Unpivot Other Columns flattens the rest, as below.
Rename and Set Types
The generic names are the last thing to fix. Attribute and Value describe nothing useful. So rename them to match your data. After that, set the correct data types.
A Real Example: Sales Matrix
Picture a sheet of regional sales by month. Regions sit in column A, months across the top. You want a pivot of sales by month and region. Unpivot makes that possible in seconds.
Troubleshooting Unpivot
All three problems below are the most common. Each has a clear cause and a quick fix.
Only some columns unpivoted
This usually means you selected the wrong set. Unpivot Columns rotates only the columns you picked. So any header you missed stays as a column. First, undo the step and start again. Then select only the columns you want to keep. Next, choose Unpivot Other Columns instead. That flattens everything else in one clean move.
A new month broke the query
A hard-coded column list is the likely cause. Unpivot Columns names each column it rotates. So a new month falls outside that list. First, replace the step with Unpivot Other Columns. That version keeps only your chosen columns fixed. Everything else rotates, including any new month. After that, fresh columns flow through on refresh.
The values came in as text or errors
Mixed content in the grid causes this. A stray label or blank sits among the numbers. First, check the Value column for odd entries. Then remove or fix those rows in the query. Next, set the Value column to a number type. Power Query will flag any cell that cannot convert. Clean those, and the column becomes fully numeric.
Frequently Asked Questions
- What does unpivot do in Power Query?+It rotates columns into rows. Each header becomes a value in a new column. The figures move into a Value column. So wide cross-tab data becomes tidy and tabular.
- What is the difference between Unpivot Columns and Unpivot Other Columns?+Unpivot Columns rotates the columns you select. Unpivot Other Columns keeps your selection and rotates the rest. So the second option catches new columns too. Therefore it is the safer, future-proof choice.
- Why should I convert a cross-tab to tabular data?+Because analysis tools expect one column per field. A cross-tab spreads one field across many columns. So a PivotTable cannot read it well. Tabular data, by contrast, pivots and filters easily.
- How do I rename the unpivoted columns?+Double-click the Attribute header and type a name. For example, rename it to Month. Then rename Value to something like Sales. Finally, set the correct data types.