logo
search
Function Problems

Convert Customer Order Data to a Pivot-Style Table in Excel

Maira MehtabMaira Mehtab Sep 28, 2026 869 views

Question details

The user needs to transform customer order data into a normalized, pivot-style table using dynamic formulas while retaining elements like the Customer PO.

Product
Microsoft Excel
Device & OS
Mac
Scenario
Transforming multi-column customer order data (including POs and product codes) into a flat, normalized table structure for better analysis.
Observed behavior
The data needs to be stacked and flattened correctly using functions like HSTACK, INDEX, SEQUENCE, and TOCOL, while dynamically repeating corresponding row identifiers.
Before you start

Ensure you are using a modern version of Excel (Microsoft 365 or Excel 2021+) that supports dynamic array functions. On a Mac, verify your app is fully updated via Microsoft AutoUpdate to ensure these functions are available.

Solution 1Recommended

Use Dynamic Array Formulas to Flatten Data

Apply a combination of dynamic array functions to automatically reshape the customer order data without manual copying and pasting.

This formula combines HSTACK, INDEX, SEQUENCE, and TOCOL to extract and reshape the multi-column data into a single, flat table. It systematically repeats the Customer PO and aligns the product codes perfectly.

1
Select the destination cell

Click on the top-left blank cell where you want the new pivot-style table to begin generating.

2
Enter the dynamic formula

Type the formula =HSTACK(INDEX(H2:H38,ROUNDUP(SEQUENCE(COUNTA(H2:H38)*5)/5,0)),INDEX(A2:A38,ROUNDUP(SEQUENCE(COUNTA(A2:A38)*5)/5,0)),INDEX(C1:G1,MOD(SEQUENCE(COUNTA(A2:A38)*5)-1,5)+1),TOCOL(C2:G38)) into the formula bar.

3
Adjust the data ranges

Modify the range references in the formula to match your specific dataset. For example, change H2:H38 for the POs, A2:A38 for customer names, C1:G1 for column headers, and C2:G38 for the actual values.

4
Execute the formula

Press Enter to apply the formula. The data will automatically spill into the adjacent columns and rows, instantly forming a normalized table.

Handling #NAME? Errors: If you receive a #NAME? error, your version of Excel does not currently support these newer functions. Update Excel to the latest version to resolve this.
Advanced Data Management

Transform and Normalize Data Easily with WPS Spreadsheet

WPS Spreadsheet provides powerful data handling tools, including robust support for array formulas, allowing you to seamlessly reshape complex order data into clean, normalized tables in seconds.

  1. 1. Open your dataset in WPS Spreadsheet: Launch WPS Office and open your existing customer order data spreadsheet.
  2. 2. Input the array formula: Select a blank destination cell and paste your flattening array formula, ensuring the cell references correspond to your data structure.
  3. 3. Calculate the array: Hit Enter. WPS Spreadsheet will instantly calculate the formulas and output your normalized pivot-style table.
Fully compatible with Microsoft Excel (.xlsx) file formats and complex formulas.Supports advanced array operations for automated data transformation.Lightweight software that runs smoothly on Mac, Windows, and Linux.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my dynamic array formula returning a #NAME? error?

The #NAME? error usually occurs if your version of Excel does not support new dynamic array functions like HSTACK or TOCOL. You need an active Microsoft 365 subscription or Excel 2021+ to use these specific functions.

Can I normalize data without using complex formulas?

Yes, you can use the Power Query feature. Go to the Data tab, click 'From Table/Range', select the columns you want to unpivot in the Power Query Editor, and choose 'Unpivot Columns' to achieve a flat table structure without manual formulas.

What does the TOCOL function do in this specific formula?

The TOCOL function takes an entire two-dimensional array or range of data (such as multiple columns of product order codes) and systematically transforms it into a single vertical column, making it ideal for unpivoting data.