Power Query Transpose: How to Flip Rows and Columns
In this article
Power Query’s transpose function swaps rows and columns in your data table, turning column headers into data rows and vice versa. This is essential when your source data is oriented sideways and you need it vertical for analysis, reporting, or merging with other datasets. No special tools or add-ins are required — this is a native feature in Excel, Power BI, and other Microsoft tools using Power Query. You must have data loaded into Power Query first.
What You'll Need
- A dataset loaded into Power Query (from Excel, CSV, database, or other source)
- Microsoft Excel 2016 or later, or Power BI Desktop
- Basic familiarity with the Power Query Editor interface
Step-by-Step
- Open your Excel workbook or Power BI Desktop file and load your data into Power Query. In Excel, select your data range and choose Data > From Table/Range. In Power BI, select Get Data and choose your source, then click Transform Data.
- Once the Power Query Editor opens, verify your data is displayed in a table format with headers. If the first row is not being used as headers, select Use First Row as Headers from the Transform tab.
- Highlight the entire table by clicking the top-left corner of the data grid (where the row and column headers meet). This ensures all rows and columns are selected for transposition. If you only want to transpose specific columns, select those columns by holding Ctrl while clicking their headers.
- Go to the Transform tab in the ribbon at the top of the Power Query Editor.
- Find and click the Transpose button. It is located in the Order group, represented by an icon showing arrows flipping rows and columns. Do not confuse this with the Pivot or Unpivot options.
- After clicking Transpose, your data will immediately flip: the original columns become rows and the original rows become columns. The first row (now a column) will contain the original column headers as values.
- Check if the new top row contains the correct headers. Since transposing turns the original column headers into data, you now need to promote the new first row to headers. Select the first row, then click Use First Row as Headers from the Transform tab again.
- Review your transposed data for accuracy. Ensure the values align correctly with the new column headers and that no unintended empty cells or duplicates were created.
- Click Close & Load (in Excel) or Close & Apply (in Power BI) to send the transposed table back to your worksheet or report canvas.
Common Mistakes
- Forgetting to promote the new first row as headers after transposing, leaving you with Row1, Row2, etc. as column names — this breaks subsequent transformations.
- Transposing only part of the table without selecting all relevant columns, causing mismatched data relationships and missing values.
- Transposing data that contains merged cells or inconsistent row lengths — Power Query will fail or produce unpredictable results. Clean data before transposing.
- Assuming the transpose function will rearrange summary rows or totals — it transposes everything, including footers. Remove totals or subtotals before transposing.
- Trying to transpose while in the Advanced Editor — the Transpose button only works in the visual interface.
Tips
- Always duplicate your original query before transposing (right-click the query in the Queries pane and select Duplicate). This preserves your source data for comparison or rollback.
- If your data has many columns and few rows, transposing can make it easier to work with in pivot tables or charts designed for vertical data.
- Use the View > Gridlines option to better visualize row/column boundaries before and after transposing.
- After transposing, consider using the Change Type feature to set data types for the new columns (e.g., Date, Number, Text) — this improves performance and prevents errors in later steps.
- For repeated transposes, record the steps as a custom function. Go to Home > Advanced Editor, copy the M code for the transpose steps, and save it as a reusable function.
- When transposing survey data or response tables, this technique is invaluable for turning respondents’ answers (columns) into records (rows) for aggregation.
Troubleshooting
- Nothing happens when I click Transpose: Ensure you have selected at least one column or row. If the entire table is not selected, the button may be grayed out. Click the top-left corner to select all.
- Headers disappeared after transposing: You forgot to click Use First Row as Headers after transposing. Go back to the Power Query Editor, select the first row, and apply Use First Row as Headers again.
- Data looks scrambled or misaligned: Your original data had uneven row lengths or empty cells. Clean your source data by removing blank rows/columns before transposing. Use Remove Rows > Remove Blank Rows to clean up.
- Power Query crashes or freezes during transpose: Your dataset is too large. Try transposing only a subset first to test. If it works, consider splitting your data into chunks or using a database instead of Excel.
- Column names are numbers like Column1, Column2: This means the original data had no headers. Go back to the source and enable Use First Row as Headers before transposing. If there were no headers, you may need to manually rename the new columns after transpose.