Power Query Problems

How to Convert Horizontal Excel Data to Vertical Format Using Power Query

Elise WilliamsElise Williams Nov 4, 2026 870 views

Question details

The user needs to transform horizontally arranged data (scale and amount) into a vertical Excel table without manually copy-pasting each value.

How to Convert Horizontal Excel Data to Vertical Format Using Power Query
Product
Microsoft Excel
Device & OS
not provided
Scenario
Restructuring a wide, horizontal dataset with paired attributes into a vertical, database-friendly layout for better analysis.
Observed behavior
The current dataset is arranged horizontally, requiring an automated transformation process using Power Query to unpivot the data columns.
Before you start

Ensure your source data does not contain entirely blank rows or columns, and properly label all column headers. Formatting your data range as an Excel Table (Ctrl+T) before importing is highly recommended.

Solution 1Recommended

Use Power Query to Unpivot and Merge Columns

This method uses Excel's Power Query (Get & Transform) to automatically unpivot paired data points, making the transformation seamless and repeatable.

Power Query allows you to flatten horizontal datasets. By unpivoting 'other' columns and using index columns to merge separated attributes (like Scale Quantity and Amount), you can accurately build a fully functional vertical dataset.

1
Convert Source Data to a Table

Select any cell in your source data range and press Ctrl+T to format it as a table. Once converted, go to the Data tab on the Excel ribbon and click 'From Table/Range' to open the Power Query Editor.

2
Unpivot the Target Columns

In the Power Query Editor, select the fixed columns you want to keep intact (e.g., ID, Material). Right-click the selected headers and choose 'Unpivot Other Columns' (or navigate to Transform > Unpivot Columns > Unpivot Other Columns).

3
Split and Duplicate the Query

Select the newly created 'Attribute' column. Go to Home > Split Column > By Delimiter, and choose to split by the rightmost space. Next, duplicate this entire query in the left pane so you have two identical queries. Rename one query to 'Scale' and the other to 'Amount'.

4
Filter and Add Index Columns

Filter the 'Scale' query so it only shows scale quantities, and filter the 'Amount' query to show only amounts. For both queries, navigate to Add Column > Index Column and select 'From 0'.

5
Merge Queries and Load Data

In the 'Scale' query, click Home > Merge Queries. Select the 'Amount' query from the dropdown and match them by clicking the Index columns in both previews. Expand the required value columns from the merged data, remove the Index column, set the data types (Whole Number for Scale, Currency for Amount), and click 'Close & Load' to export the vertical table to a new worksheet.

Use Power Query to Unpivot and Merge Columns
Dynamic Data Updating: Once your Power Query connection is established, any new data added to the original horizontal table can be automatically transformed by clicking 'Refresh All' on the Data tab.
Free Microsoft Office alternative

Try WPS Office for Your Spreadsheet and Data Processing Needs

While Power Query is a built-in feature of Microsoft Excel tailored for complex data modeling, WPS Office offers a highly compatible, lightweight, and completely free alternative for your everyday data processing and spreadsheet tasks. Enjoy a familiar interface and reliable analysis tools without expensive subscription fees.

100% compatible with Microsoft Excel file formats (.xlsx, .xls, .csv)Built-in advanced data analysis tools including PivotTables and Data TranspositionLightweight application that runs smoothly on all systemsFree to use with a familiar, easy-to-navigate tabbed interface
microsoft office alternative - wps office

Frequently Asked Questions

Can I convert horizontal data to vertical format without using Power Query?

Yes, you can use the built-in Transpose feature for simpler datasets. Select and copy your horizontal data, right-click the destination cell, select Paste Special, and check the 'Transpose' box. However, unlike Power Query, this method is manual and will not automatically update if the original data changes.

Why is an Index column required when merging queries?

Adding an Index column to both the split Scale and Amount queries provides a unique identifier for each row. This guarantees that when you merge the queries back together, the corresponding scales and amounts align perfectly on the same row without mixing up the data.

How do I update my vertical table if the original horizontal data changes?

Because Power Query maintains a live connection to your source table, you do not need to repeat the unpivot process. Simply navigate to the Data tab on your Excel ribbon and click 'Refresh All'. Your vertical table will automatically process and append the new horizontal data.