top of page

You are learning Power Query in MS Excel

How to pivot data from a long format to a wide format in Power Query?

Here's how to pivot data from a long format to a wide format in Power Query:

1. Select your data: Ensure you have loaded your data into Power Query Editor.
2. Transform data: Navigate to the "Transform" tab on the Power Query ribbon.
3. Unpivot Other Columns: Click on "Unpivot Other Columns" under the "Unpivot" group.
4. Specify "Value" Column: In the "Unpivot Other Columns" window, choose the column that contains the values you want to distribute across the new wide format. This will typically be the data column with varying values.
5. "Unpivot by" Column Selection: Under "Unpivot by" select the column(s) that define the unique categories for your new wide format headers. These columns will become your header names.
6. Optional Advanced Settings: The "Advanced" options allow you to choose an aggregation function (e.g., Sum, Average) for the "Value" column if you have multiple rows with the same category combination. You can leave it as "Don't Aggregate" if you just want to bring the raw values across.
7. Click OK: Confirm your selections and click "OK" to unpivot the data.

After following these steps, your data will be transformed from long format to wide format. The unpivoted columns will become your new headers, and the "Value" column will be distributed accordingly across those headers.

Additional Tips:

* You can rename the unpivoted columns (headers) for better clarity in your data model.
* If you encounter errors or unexpected results, double-check your selections for the "Value" and "Unpivot by" columns.
* Consider using the Power Query formula editor for more advanced pivoting scenarios with custom logic.

By following these steps, you can effectively transform your long format data into a wide format for easier analysis and manipulation within Power Query.

bottom of page