Power Query Problems

How to Stack Repeated Excel Column Groups Vertically

Bushra ParveenBushra Parveen Oct 12, 2026 869 views

Question details

The user needs to vertically stack multiple repeated column groups (such as Job, Hours, and Location) from a large dataset, ensuring the corresponding record ID is repeated on every output row.

How to Stack Repeated Excel Column Groups Vertically
Product
Excel
Device & OS
not provided
Scenario
Reorganizing a wide dataset containing numerous repeated attribute sets across thousands of rows into a clean, unpivoted tabular format suitable for analysis.
Observed behavior
The data is currently spread horizontally across up to 90+ column groups, requiring manual or automated reshaping to stack the columns sequentially while maintaining index alignments.
Before you start

Before applying these complex formulas, ensure your spreadsheet software supports modern Dynamic Array functions (such as VSTACK and LAMBDA) and consider converting your dataset into an official Table for easier referencing.

Solution 1Recommended

Use Dynamic Array Formulas to Stack Columns

Best for users who want a direct, formula-based approach to reshape and stack repeated columns without using external data editors.

You can combine modern dynamic array functions like VSTACK, REDUCE, LAMBDA, and CHOOSECOLS to systematically loop through your wide dataset and stack each group of columns underneath the previous one.

This approach recalculates automatically when your source data changes, eliminating the need to refresh data connections manually.

1
Define the output location

Select an empty cell in a new worksheet where you want the stacked data headers to begin.

2
Enter the REDUCE and VSTACK formula

Type the following dynamic array formula, adjusting the ranges to match your specific dataset columns: =VSTACK(A1:D1,DROP(REDUCE("",SEQUENCE(COUNTIF(A1:G1,"*job*"),,1,3),LAMBDA(a,i,VSTACK(a,HSTACK(A2:A3,CHOOSECOLS(B2:G3,i,i+1,i+2))))),1))

3
Execute the formula

Press Enter. The formula will iterate through your defined column intervals and dynamically spill the vertically stacked rows into the cells below.

Dynamic Spill Range: Ensure the cells below and to the right of your formula cell are completely empty, or you will encounter a #SPILL! error.
Efficient Data Reshaping with WPS Office

Use WPS Spreadsheet to Stack Data Flawlessly

WPS Office offers comprehensive support for modern dynamic array functions, allowing you to seamlessly process wide datasets and unpivot repeated columns without complicated setup.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the file containing your wide, repeated column groups.
  2. 2. Select the destination: Navigate to a blank worksheet or empty area and select a cell for your output.
  3. 3. Apply the array formula: Input the array formula utilizing VSTACK and CHOOSECOLS to reference your data.
  4. 4. Generate the stacked results: Press Enter to instantly populate and spill the reshaped columns vertically.
Fully compatible with Microsoft Excel formulas, including VSTACK, HSTACK, and LAMBDA.Lightweight architecture ensures smooth performance even when calculating thousands of rows.Free to use with an intuitive, tabbed interface for managing multiple worksheets easily.
microsoft office alternative - wps office

Frequently Asked Questions

Can I stack columns without using Power Query?

Yes. If you are using a modern spreadsheet version, you can combine dynamic array functions like VSTACK, REDUCE, and CHOOSECOLS to programmatically stack columns. This mimics the unpivot behavior of Power Query using entirely formula-based logic.

Why is my dynamic array formula returning a #SPILL! error?

A #SPILL! error occurs when the destination range required to display all the stacked data is obstructed. Clear any text, formatting, or hidden characters in the cells below and adjacent to your formula to resolve this.

Is there a limit to how many rows I can stack?

Spreadsheet software typically supports up to 1,048,576 rows per sheet. However, heavily nested array formulas processing tens of thousands of rows might cause calculation slowdowns. For highly dense datasets, using Power Query or specialized database tools is recommended.

What is the purpose of CHOOSECOLS in the formula?

The CHOOSECOLS function extracts specific columns from an array by their index numbers. In a stacking formula, it allows you to precisely target the next repeated group (e.g., Job, Hours, Location) for each iteration so they align properly in the output.