Power BI How to Switch Columns to Rows
In this article
Switching columns to rows in Power BI, also known as unpivoting, transforms your data from a wide format to a long format. This is essential when you need to compare values across categories in visuals like bar charts or tables, or when preparing data for time-based analysis. You must have your data loaded into Power BI Desktop and be in the Power Query Editor to perform this operation. No external tools or plugins are required — this is a built-in feature.
What You'll Need
- Power BI Desktop installed (latest version recommended)
- A table in your data model with columns you want to transpose
- Access to the Power Query Editor (available after loading data)
Step-by-Step
- Open Power BI Desktop and load your data source. This can be Excel, CSV, SQL Server, or any other supported data connector. Ensure your table contains the columns you wish to switch from horizontal to vertical.
- Once your data is loaded, click on the Transform Data button in the Home tab. This opens the Power Query Editor.
- In the Power Query Editor, locate the table you want to modify. If you have multiple queries, select the correct one from the list on the left-hand side.
- Hold down the Ctrl key (Cmd on Mac) and click on the column headers you want to unpivot. These are typically the data columns that contain values you want to turn into rows — for example, sales figures for Jan, Feb, Mar. Do not select identifier columns like Product ID, Region, or Date if they should remain as unique row labels.
- With the target columns selected, go to the Transform tab in the ribbon at the top.
- Click on Unpivot Columns. This action converts your selected columns into two new columns: Attribute (which holds the original column names) and Value (which holds the corresponding data values).
- After unpivoting, you may want to rename the new columns for clarity. Right-click the Attribute column header and choose Rename. Change it to something like Month or Category. Do the same for the Value column, renaming it to Sales, Revenue, or another appropriate term.
- If you have columns you did not unpivot (like Product ID or Region), ensure they remain as they are — they now act as unique identifiers for each row in the new long-format table.
- Review your data. Each original row should now be split into multiple rows, one for each unpivoted column. For example, one product with sales for three months will now appear as three separate rows.
- Click Close & Apply in the top-left corner to save your changes and return to the main Power BI report view.
Common Mistakes
- Unpivoting identifier columns like IDs or dates — this breaks the uniqueness of your data and creates duplicates or meaningless combinations.
- Forgetting to rename the new Attribute and Value columns, leading to confusion later when building visuals.
- Selecting too many columns to unpivot, including text columns that don't contain numeric values — this can create misleading visuals if you later try to aggregate non-numeric data.
- Not checking data types after unpivoting. The Value column defaults to text or general type; you may need to change it to Decimal Number or Whole Number manually by clicking the data type icon (ABC/123) in the column header.
- Unpivoting all columns without filtering out empty or irrelevant ones first, which inflates your dataset with useless rows.
Tips
- Before unpivoting, use the Filter icon on any column to remove rows with null or blank values — this reduces file size and improves performance.
- If you're working with quarterly or monthly data, unpivot only the value columns and keep the time dimension (e.g., Year) intact as a separate column to enable time intelligence later.
- Use the Group By function after unpivoting if you need to aggregate values across categories — for example, summing sales by region and month.
- Consider duplicating your query before unpivoting if you want to keep the original wide format for other reports or calculations.
- Use column headers that are consistent and clean before unpivoting. Avoid spaces, special characters, or mixed casing — they can cause issues when using DAX formulas later.
- After unpivoting, create a calculated column using
IForSWITCHin DAX to map Attribute values to more readable labels (e.g., convert "Jan" to "January").
Troubleshooting
- The Unpivot option is grayed out. This means you haven’t selected any columns, or you’ve selected only identifier columns. Select at least two numeric or text columns containing the values you want to convert.
- Values appear as text after unpivoting. Click the column header of the Value column, then select the correct data type from the ribbon (e.g., Decimal Number). If data shows errors, check for non-numeric entries like "N/A" or "-" in your source — clean these in Power Query using Replace Values or Remove Errors.
- Too many rows are created and performance is slow. Check if you accidentally unpivoted columns that shouldn’t be transformed. Remove unnecessary columns before unpivoting. Use the Remove Columns option if needed.
- The Attribute column shows unexpected names. This happens if your source column headers were changed after import. Go back to your source file (Excel, CSV) and ensure column names are consistent and correctly spelled before reloading the data.
- Changes don’t appear in visuals after clicking Close & Apply. Refresh the visuals manually by clicking the refresh icon in the top-right of the report view. Also check if your new unpivoted table is being used in the visual — sometimes visuals still reference the original table.
Frequently Asked Questions
Can I switch rows back to columns in Power BI?
Yes, using the Pivot function. Select the Attribute column (e.g., Month), then go to Transform > Pivot Column. Choose the Value column as the Values column and select an aggregation (usually Sum). This reverses the unpivot operation.
Does unpivoting affect my data model relationships?
No, as long as you preserve the key columns (like Product ID or Region) that were used to link tables. Unpivoting only changes how data is structured within a single table — relationships remain intact.
Can I unpivot data in the report view, not just Power Query?
No. Unpivoting is a data transformation step that must be done in Power Query Editor. Report view only allows visualization and filtering of already transformed data.
What’s the difference between unpivot and pivot in Power BI?
Unpivot converts columns into rows — turning wide data into long data. Pivot does the opposite: converts rows into columns — turning long data into wide data. They’re inverse operations.
Why is my Value column showing zeros after unpivoting?
This usually means the original columns contained non-numeric data that couldn’t be converted. Check your source data for text values like "N/A", "-", or spaces. Clean them with Replace Values or Remove Errors in Power Query before unpivoting.
Will unpivoting increase my file size?
Yes, because each original row becomes multiple rows. A table with 100 rows and 5 value columns becomes 500 rows. This can affect performance if your dataset is very large. Use filters or aggregate data before importing if possible.