Power BI Rows to Columns: Complete Pivot & Unpivot Guide (2026) | Flexa Intel

Power BI Guide  ·  Updated July 2026  ·  12 min read  ·  Flexa Intel Team

Power BI Rows to Columns: Complete Pivot & Unpivot Guide (2026)

Quick Answer To convert rows to columns in Power BI, use Power Query Pivot Column (Transform → Pivot Column) — this reshapes data at the model level before it reaches your visuals. To convert columns to rows, use Power Query Unpivot Columns. For a dynamic pivot that users can restructure after publishing without going back to Desktop, use Flexa Tables from AppSource — it adds drag-and-drop pivot behavior in Power BI Service with no DAX or Power Query required.
2directions: Pivot (rows → columns) and Unpivot (columns → rows) — both done in Power Query Editor
Tallformat is almost always correct for Power BI data models — unpivot wide source data before modeling
0Power Query steps needed for dynamic pivot after publishing — Flexa Tables handles it in the visual layer

1. Pivot vs Unpivot — What Each Does and When to Use It

Pivot and unpivot are data reshaping operations. They don't change the data — they change the shape of the table. Understanding which direction you need is the most important step before opening Power Query.

Pivot converts rows to columns; Unpivot converts columns to rowsTwo diagrams side by side. Left: Unpivot — a wide table with columns Jan, Feb, Mar being converted to a tall table with Attribute and Value columns. Right: Pivot — a tall table with Month and Revenue rows being converted to a wide table with one column per month.UNPIVOT — columns to rows(most common — normalize wide source data)ProductJanFebMarWidget A$120$135$148Widget B$90$95$102Wide format (problem for DAX)Transform → Unpivot ColumnsProductMonthRevenueWidget AJan$120Widget AFeb$135Widget AMar$148Tall format ✓ (correct for DAX)PIVOT — rows to columns(less common — reshape for specific report layout)ProductMonthRevenueWidget AJan$120Widget AFeb$135Widget AMar$148Transform → Pivot ColumnProductJanFebMarWidget A$120$135$148
Unpivot (left) converts wide source data to tall format for the data model. Pivot (right) converts tall data to wide — less common in Power BI, typically done at the visual layer instead.
OperationDirectionWhen to usePower Query tool
UnpivotColumns → RowsSource data has one column per period (Jan, Feb, Mar…) and you need a normalized tall table for DAX and the Matrix visualTransform → Unpivot Columns
PivotRows → ColumnsSource data has one row per period and you need a fixed wide table for a specific report layout (rare — usually better to do this at the visual layer)Transform → Pivot Column
Default to unpivot. In Power BI, the data model should almost always be in tall (normalized) format. The Matrix visual and DAX time intelligence functions are designed for tall data — they generate column headers dynamically from a dimension field. Wide format (one column per period) breaks DAX calculations and requires model changes every time a new period is added.

2. How to Unpivot Columns to Rows (Power Query)

Unpivot is used when your source data arrives in wide format — one column per month, quarter, region, or scenario — and you need to reshape it into tall format before loading into the data model.

Step-by-step: Unpivot in Power Query

  1. Open Power Query Editor. In Power BI Desktop: Home → Transform Data.
  2. Identify the columns to unpivot — the columns whose headers will become row values. In a typical financial export, these are the month or quarter columns (Jan, Feb, Mar, Q1, Q2…).
  3. Select the columns to unpivot. Click the first column header, then Ctrl+Click each additional column to select all. Alternatively, select the columns you want to keep as rows, then use "Unpivot Other Columns" — this is safer because it automatically handles new columns added to the source.
  4. Unpivot. With columns selected: Transform → Unpivot Columns. Power Query creates two new columns: Attribute (containing the original column headers) and Value (containing the cell values).
  5. Rename the new columns. Double-click Attribute and rename it to Month (or Quarter, Period, etc.). Double-click Value and rename it to Revenue (or the appropriate measure name).
  6. Set correct data types. The Value column will likely be text — change it to Decimal Number or Whole Number (click the data type icon in the column header).
  7. Close & Apply. Home → Close & Apply. The unpivoted table is now available in your data model.
Use "Unpivot Other Columns" instead of "Unpivot Columns" when possible. "Unpivot Columns" unpivots exactly the columns you selected — if new columns appear in the source data (e.g. a new month), they are NOT unpivoted automatically. "Unpivot Other Columns" unpivots everything except the columns you selected to keep — so new columns in the source are automatically included. This makes the query more robust to schema changes in the source.

Unpivot with multiple identifier columns

If your source table has multiple columns that should remain as row identifiers (e.g. Product AND Region AND Year, with month columns to unpivot), select all the identifier columns first, then use Transform → Unpivot Other Columns. This preserves all identifiers on each row of the unpivoted output.

// Power Query M code equivalent of Unpivot Other Columns:
= Table.UnpivotOtherColumns(
    Source,
    {"Product", "Region", "Year"},  // columns to keep as identifiers
    "Month",                          // new column for attribute names
    "Revenue"                         // new column for values
)

3. How to Pivot Rows to Columns (Power Query)

Pivot is used less frequently in Power BI than unpivot — most of the time, pivoting should happen at the visual layer (Matrix visual or Flexa Tables), not in the data model. Use Power Query Pivot when a downstream system or specific report layout requires a fixed wide table.

Step-by-step: Pivot Column in Power Query

  1. Open Power Query Editor. Home → Transform Data.
  2. Select the column whose values will become column headers. Click the column header — for a month pivot, this is the Month column.
  3. Go to Transform → Pivot Column.
  4. In the Pivot Column dialog: select the Values Column (the column containing the numbers, e.g. Revenue). Set Aggregate Value Function to Sum (or Don't Aggregate if values are unique per row).
  5. Click OK. Power Query creates one column per unique value in the selected column.
  6. Sort columns if needed. Power Query does not guarantee column order — you may need to reorder columns manually: right-click a column header → Move → To Beginning/End, or drag columns.
  7. Close & Apply.
Pivot Column creates a fixed number of columns. If your Month column has 12 unique values today, you get 12 columns. If the source data adds a 13th month next refresh, Power Query adds a 13th column — but your Matrix visual won't display it until you manually update the visual in Desktop and republish. This is the main reason to prefer visual-layer pivoting (Matrix or Flexa Tables) over Power Query Pivot for time-based cross-tabs.

Controlling which values become columns

If you only want specific values to become columns — for example, only the last 12 months rather than all available months — filter the column before pivoting:

// Filter to last 12 months before pivoting
= Table.SelectRows(
    Source,
    each [Month] >= Date.AddMonths(Date.From(DateTime.LocalNow()), -12)
)

Apply this filter step before the Pivot Column step in Power Query.

4. Pivot at the Visual Layer — Matrix and Flexa Tables

For most Power BI reporting use cases, you should not pivot in Power Query at all. Instead, keep the data model in tall format and let the visual generate the cross-tab layout dynamically. This gives you two options:

Option A — Matrix visual (fixed after publishing)

Place your row dimension in Rows, your column dimension (Month, Quarter, Scenario) in Columns, and your measure in Values. The Matrix generates a cross-tab at render time — no Power Query pivot needed. The limitation: the layout is locked after publishing. Users can filter with slicers but cannot restructure the rows and columns or add variance columns without going back to Desktop.

Option B — Flexa Tables (dynamic after publishing)

Flexa Tables is a Microsoft-certified custom visual that adds true drag-and-drop pivot behavior to published Power BI reports. Unlike the Matrix visual, users can restructure rows and columns, show and hide columns, and add variance columns (MoM, YoY, Actual vs Budget) directly in Power BI Service — without IT involvement, without Desktop, without republishing.

Power Query PivotMatrix VisualFlexa Tables
Where pivot happensData model (query)Visual layer (render time)Visual layer (render time)
Dynamic after publishingNoNoYes
New columns when data growsAuto (can break visuals)Auto (always works)Auto (always works)
Variance columns (MoM/YoY)NoRequires DAXBuilt-in, no DAX
User restructures after publishNoNoYes
Best forFixed layouts, downstream systemsFixed dashboards with known layoutFinance/ops teams needing self-service
For Finance teams specifically: if your team keeps asking "can you pivot it by department instead of by month?" or "can you add a column comparing to last quarter?" — that's a signal to use Flexa Tables rather than rebuilding the Power Query pivot or writing new DAX. Flexa Tables is $2.99/user/month, Microsoft-certified, and available on AppSource with a free trial. See how it works →

5. Decision Guide: Which Approach to Use

SituationRecommended approach
Source data has one column per month (Jan, Feb, Mar…) and you need it in tall format for DAXUnpivot in Power Query — normalize before modeling
Source data is already tall and you want a cross-tab report with months as columnsMatrix visual — put Month in Columns field well, no Power Query needed
You need a fixed wide table for a downstream system or Excel exportPivot Column in Power Query — but document the column count so you catch schema changes
Finance users need to swap rows/columns or add variance comparisons after publishingFlexa Tables — dynamic pivot in Power BI Service without IT
You have both Actuals and Budget as separate wide tables from two different systemsUnpivot both, add a Scenario column (Actual / Budget), then Append Queries to create a single fact table
Source data changes shape every month (new columns appear)Unpivot Other Columns (not Unpivot Columns) — handles new columns automatically

6. Common Errors and Fixes

Error: "Expression.Error: The column 'April' of the table wasn't found"

This happens when you used Pivot Column and a new unique value appears in the source data that wasn't there when you built the query. Power Query tries to reference a column that doesn't exist yet. Fix: switch the query to use Unpivot instead of Pivot, and do the cross-tab layout in the Matrix visual. Or add an explicit filter before the pivot step to limit to a known set of values.

Error: Unpivot creates null rows

When source data has blank cells (a product with no sales in February, for example), Unpivot creates rows with null in the Value column. Fix: after the Unpivot step, add a filter step to remove nulls: Home → Remove Rows → Remove Blank Rows. Or keep the nulls if you want to show zeros in the Matrix — use IF(ISBLANK([Revenue]), 0, [Revenue]) in your measure.

Error: Pivot Column returns "Value.Error" for non-numeric values

Pivot Column with a Sum aggregation fails when the Values column contains text instead of numbers. Fix: before the Pivot step, change the Values column data type to Decimal Number (click the data type icon → Decimal Number). If the column contains mixed text and numbers, add a step to replace errors: Transform → Replace Errors → 0.

Pivot columns appear in wrong order (alphabetical instead of chronological)

Power Query does not sort pivot column headers — they appear in the order unique values are encountered in the data. Fix: after the Pivot step, add a Reorder Columns step (right-click column headers → Move, or drag). Or pre-sort the source table by the date column before the Pivot step so months are encountered in chronological order.

Unpivot creates too many rows (cartesian explosion)

If your source table has both a wide format and duplicate identifier rows, Unpivot multiplies the rows. Fix: before unpivoting, ensure each combination of identifier columns (Product, Date, etc.) is unique. Use Remove Duplicates on the identifier columns first, or Group By to aggregate before unpivoting.

Skip the Power Query pivot — make your cross-tab dynamic after publishing

Flexa Tables adds drag-and-drop pivot and built-in MoM/YoY/Actual vs Budget variance to published Power BI reports — no Power Query pivot, no DAX, no Desktop access needed. Microsoft-certified, free trial on AppSource.

Get Free Trial on AppSource →

FAQ

How do I convert rows to columns in Power BI?

Use Power Query's Pivot Column feature: open Power Query Editor → select the column whose values will become column headers → Transform → Pivot Column → select the Values Column → set aggregate function to Sum → click OK. For a dynamic pivot that users can restructure after publishing, Flexa Tables handles this in the visual layer without Power Query.

How do I unpivot columns to rows in Power BI?

Open Power Query Editor → select the columns to unpivot → Transform → Unpivot Columns. Power Query creates Attribute and Value columns. Rename them to match your data (e.g. Month and Revenue). Use "Unpivot Other Columns" instead of "Unpivot Columns" when you want new source columns to be automatically included on future refreshes.

What is the difference between pivot and unpivot in Power BI?

Pivot converts rows into columns — it takes unique values from one column and makes each a new column header. Unpivot does the opposite — it converts multiple columns into two columns (one for the original header names, one for the values). In Power BI, unpivot is far more commonly needed because the data model should be in tall (normalized) format for DAX and the Matrix visual to work correctly.

Can I pivot data in Power BI without Power Query?

Yes — the Matrix visual pivots data at the visual layer without changing the data model. Place your row dimension in Rows, your column dimension in Columns, and your measure in Values. For a dynamic pivot where users can restructure after publishing, Flexa Tables adds drag-and-drop pivot in Power BI Service without DAX or Power Query.

Why does Power BI Pivot Column create extra columns when data refreshes?

Pivot Column creates one column per unique value in the pivoted field. If new values appear on refresh (e.g. a new month), Power Query adds new columns — which can break report visuals. To prevent this, filter the pivoted field to a known set of values before pivoting, or switch to visual-layer pivoting with the Matrix visual or Flexa Tables.

When should I use Unpivot vs keeping data in wide format?

Unpivot (tall format) is almost always correct for Power BI data models. Tall format works correctly with DAX time intelligence, supports any number of periods without model changes, and allows the Matrix visual to generate columns dynamically. Wide format is only acceptable when the column count is permanently fixed and the data will never add new columns.

FI
Flexa Intel Team Power BI custom visuals for tables, charts, design & analytics. Makers of Flexa Tables — the pivot and variance visual for Power BI.
flexaintel.com
facebooklinkedintwittermail