The Table.Transpose function in Power Query flips a table's orientation, turning rows into columns and columns into rows. To achieve this, you select the Transform tab in the Power Query Editor and click the Transpose button, or manually enter Table.Transpose(Source) in the formula bar. This is primarily used when data is provided in a cross-tab format where categories are listed horizontally but need to be vertical for analysis.

What You'll Need

  • Microsoft Excel (with Power Query integrated) or Power BI Desktop.
  • A data source (CSV, Excel Table, SQL Database, etc.) already loaded into the Power Query Editor.
  • A basic understanding of the difference between rows and columns in a tabular dataset.

Step-by-Step

  1. Open Power Query Editor: In Excel, go to the Data tab, select Get Data, and choose your source. If the data is already in your workbook, select the table and click Get Data > From Table/Range. In Power BI, click Transform Data from the Home ribbon.
  2. Prepare Your Headers: Before transposing, check if your current column headers contain data that needs to be preserved. Table.Transpose does not treat headers as data; it only transposes the cells within the table body. If your headers are actually data points (like dates or product names), go to the Transform tab and select Use First Row as Headers (or vice versa, Use Headers as First Row) to ensure the labels are moved into the grid before the flip.
  3. Execute the Transpose: Navigate to the Transform tab on the top ribbon. In the Any Column group, click the Transpose button. You will see the table immediately shift: what was the first column becomes the first row, and what was the first row becomes the first column.
  4. Verify Data Types: Power Query often resets column data types to "Any" after a transpose because the original types (e.g., Date, Currency) no longer align with the new column structure. Look at the icon to the left of each column header. Click the icon and select the correct data type (Text, Whole Number, Decimal, etc.) for each new column.
  5. Promote New Headers: After transposing, your actual headers are likely sitting in the first row of the data. To fix this, go to the Home tab and click Use First Row as Headers. This moves the first row of values into the official column header positions.
  6. Clean Up Remaining Columns: If the transpose created unnecessary columns (such as empty columns from the original row ends), right-click the column header and select Remove.
  7. Apply Changes: Once the orientation is correct and types are set, go to the Home tab and click Close & Apply to load the transposed data back into your spreadsheet or data model.

Common Mistakes

One of the most frequent errors is transposing a table while the headers are still set as official column names. Because Power Query treats the header row as metadata rather than actual table content, the headers are discarded during the transpose process. This results in the loss of your labels. Always demote headers to the first row using Use Headers as First Row before clicking Transpose.

Another common mistake is confusing Transpose with Unpivot. Transposing simply rotates the entire table 90 degrees. Unpivoting, however, transforms columns into attribute-value pairs. If you have a table with months as columns (Jan, Feb, Mar) and you want a single "Month" column and a single "Value" column, you need the Unpivot Columns feature, not Table.Transpose.

Users also frequently forget to re-assign data types. Because a column that previously held "Sales Figures" might now hold "Employee Names" after a transpose, the automatic type detection can fail or assign a generic "Any" type. This can cause errors in downstream calculations or DAX formulas in Power BI if not corrected immediately.

Tips

To maintain a clean workflow, name your steps in the Applied Steps pane. Instead of leaving it as "Transposed Table," right-click the step and rename it to something like "Rotate_Sales_Data." This makes the query much easier to audit later.

If you are dealing with a very large dataset, be mindful that transposing can be memory-intensive. Power Query must load the entire table into memory to calculate the new dimensions. If you encounter performance lag, try to filter out unnecessary rows or columns before performing the transpose operation.

Combine Transpose with the "Fill Down" or "Fill Up" tools. Often, transposed data contains null values where a label was only present in the first cell of a group. By using Transform > Fill > Down after transposing, you can quickly populate those gaps and create a clean, normalized dataset.

Troubleshooting

The headers disappeared after I transposed: This happens because you transposed the table while the labels were in the header row. To fix this, go back to the step immediately before the Transpose step in the Applied Steps pane. Click the gear icon or use the Transform tab to select Use Headers as First Row. Then, re-run the Transpose step. Your labels will now be preserved as part of the data grid.

Data types are showing as "Any" or are incorrect: This is standard behavior for the Table.Transpose function. The solution is to manually define the types. Select all columns (Ctrl+A), go to the Transform tab, and use the Data Type dropdown to set them to Text, or select columns individually for more precision.

The table looks distorted or has too many nulls: This usually indicates that the original source table had trailing empty columns or rows that were not visible in the preview. Go back to the source step and use the Remove Columns or Remove Rows (Remove Blank Rows) options to clean the perimeter of your data before transposing.

The "Transpose" button is greyed out: Ensure you are in the Power Query Editor window and that you have a Table object selected. If you are currently editing a specific cell or are in a different view, the Transform options may be unavailable.

Frequently Asked Questions

How is Table.Transpose different from Unpivot?

Transpose rotates the entire table 90 degrees, turning every row into a column. Unpivot takes a set of columns and collapses them into two columns: one for the original column header (Attribute) and one for the value (Value). Use Transpose for layout changes and Unpivot for data normalization.

Can I transpose a table with different data types in one row?

Yes, but Power Query will convert the resulting columns to the "Any" data type. Since a single column cannot hold multiple data types (like a Date and a String) while maintaining a strict type, Power Query defaults to the most flexible type until you manually redefine them.

Does transposing a table affect the original data source?

No. Power Query is a non-destructive transformation tool. It reads the data from the source and applies a series of steps to the view of that data. The original Excel file or database remains unchanged.

Can I use Table.Transpose in the M formula language?

Yes. The ribbon button is simply a shortcut for the M function Table.Transpose(table). You can enter this directly into the formula bar or within the Advanced Editor to create more complex dynamic transformations.

Why does my table have so many "Column1", "Column2" names after transposing?

Power Query assigns generic names because the original row indices do not have names. To fix this, use the Use First Row as Headers option from the Home tab to promote your transposed data labels to the header position.