Function Problems

How to Reshape Excel Data Using SCAN, GROUPBY, and PIVOTBY Functions

Ayan MasoodAyan Masood Nov 10, 2026 869 views

Question details

The user needs to restructure un-normalized band combinations and feature data into organized layouts using modern array formulas.

Reshaping Excel Data Using SCAN, GROUPBY, and PIVOTBY
Product
Excel
Device & OS
not provided
Scenario
Transforming non-standard data tables into grouped or pivoted layouts directly via formulas without manual copying or pasting.
Observed behavior
The source data is not arranged in a normalized format, so the arrays must be reconstructed in memory before generating the final outputs.
Before you start

Ensure you are using a recent version of Excel or WPS Office that supports modern dynamic array functions such as LET, SCAN, GROUPBY, and PIVOTBY. Check your source table headers and exact column references before building the formulas.

Solution 1Recommended

Reconstruct and Group Data using SCAN and GROUPBY

Use the SCAN function to carry category labels down the rows and GROUPBY to summarize the data into a structured layout.

When dealing with un-normalized data, you often have headers mixed into the same column as the data points. By combining LET, SCAN, and TEXTAFTER, you can create virtual arrays in memory that correctly associate each row with its proper category.

1
Define your variables with LET

Click an empty cell where you want the new layout to spill. Type =LET( to begin your formula. Define the starting text strings you need to search for, such as bwcs, "BandwidthCombinationSet:".

2
Use SCAN to fill down labels

Define your 'band' array by using the SCAN function to carry the band label down empty or intermediate rows: band, SCAN("", Table1[Column1], LAMBDA(a, v, IF(LEFT(v,16)="Band Combination", v, a))).

3
Extract specific text

Define your 'sets' array using TEXTAFTER to pull the set names cleanly: sets, IF(LEFT(Table1[Column1],24)=bwcs, TEXTAFTER(Table1[Column1], bwcs), "").

4
Output using GROUPBY

Filter out the blank rows and use the GROUPBY function to aggregate the arrays. Your final line in the LET function should look like: result, GROUPBY(band, sets, ARRAYTOTEXT, , 0, , rptfilter).

Reconstruct and Group Data using SCAN and GROUPBY
Spill Range Automatically Created: Because these are dynamic arrays, the final formula will automatically spill the formatted output into the adjacent cells. Ensure you have enough empty space below and to the right of your formula cell.

Handle Advanced Data Reshaping with WPS Spreadsheet

WPS Office supports powerful data handling and dynamic array functionality. You can write complex formulas to analyze and restructure large datasets smoothly without relying on expensive software subscriptions.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open the .xlsx file containing your un-normalized data.
  2. 2. Access the Formula tab: Navigate to the 'Formulas' tab on the top ribbon and explore the 'Insert Function' menu if you need to reference specific dynamic array syntax.
  3. 3. Write your array formula: Select the target cell and type your LET function in the formula bar, defining your SCAN and data grouping variables.
  4. 4. Generate the output: Press Enter to instantly execute the dynamic array and spill the reshaped data matrix directly into your worksheet.
Supports modern dynamic array functions for advanced data analysis and reshaping.Complete compatibility with Microsoft Excel (.xlsx) formats and standard formula syntax.Built-in formula evaluation tools for debugging complex nested arrays.
microsoft office alternative - wps office

Frequently Asked Questions

What does the SCAN function do in Excel?

The SCAN function applies a custom LAMBDA calculation to each item in an array and returns an array of successive results. It is highly useful for filling down values, carrying forward categories, or calculating running totals.

Why am I getting a #NAME? error when using GROUPBY or PIVOTBY?

The #NAME? error typically means your version of the spreadsheet software does not support these specific functions yet. GROUPBY and PIVOTBY are recent additions; ensure you are on the latest Microsoft 365 update or using a supported build of WPS Office.

How is TEXTAFTER different from standard string functions like RIGHT or MID?

TEXTAFTER dynamically returns the text that occurs after a specified character or substring (like a delimiter). This removes the need to manually calculate complex string lengths with FIND and LEN combinations.

Can I use multiple dynamic array functions together?

Yes. Functions like SCAN, FILTER, and TEXTAFTER are frequently nested inside a LET function. This lets you clean, fill, and rebuild data arrays step-by-step in memory before passing them to a final layout function like PIVOTBY.