How to Filter Duplicate Values from Dynamic Excel Arrays
Question details
The user needs to extract records from a dynamic array where the value in the first column appears more than once.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Combining data from multiple tables into a dynamic array and attempting to filter out strictly unique rows to analyze the duplicates.
- Observed behavior
- The standard COUNTIF function fails and returns an error because it does not accept an in-memory calculated array as its range argument.
Ensure you are using a spreadsheet application version that supports modern dynamic array functions such as LET, FILTER, VSTACK, and HSTACK.
Filter Duplicates Using MAP, LAMBDA, and SUM
Since COUNTIF does not accept in-memory dynamic arrays, use a combination of MAP and SUM to evaluate the occurrences of each value.
This method loops through the target column using the MAP and LAMBDA functions, summing up the boolean matches to determine if a value appears more than once.
Use the LET function to define your combined data. For example, combine your tables using VSTACK and HSTACK to create a unified array named 'tbl'.
Define 'col' inside the LET function using CHOOSECOLS(tbl, 1) to isolate the first column of your combined array for duplicate checking.
Apply the logic MAP(col, LAMBDA(r, SUM(N(col=r))>1)) to iterate through each row and check if its value appears more than once in the column.
Wrap the MAP logic inside a FILTER function like FILTER(tbl, [MAP logic], "") to return only the rows that meet the duplicate condition.

Filter Duplicates Using UNIQUE and XMATCH
A cleaner alternative that avoids MAP and BYROW by identifying values that appear exactly once and excluding them.
Easily Handle Dynamic Arrays and Complex Formulas in WPS Spreadsheet
WPS Office provides robust support for modern dynamic array functions like FILTER, UNIQUE, and XMATCH, allowing you to manipulate and filter complex datasets without limitations.
- 1. Open your data: Launch WPS Spreadsheet and open the workbook containing your dataset.
- 2. Select target cell: Click on the empty cell where you want the dynamic array results to spill over.
- 3. Enter the formula: Type out your dynamic array formula using LET, FILTER, and UNIQUE.
- 4. Execute the function: Press Enter to automatically calculate and populate the filtered duplicate records.

Frequently Asked Questions
Why doesn't COUNTIF work with dynamic arrays?
The COUNTIF and COUNTIFS functions require a physical worksheet range as their first argument. They cannot process in-memory calculated arrays (like those generated by VSTACK or CHOOSECOLS), which results in a formula error.
What does the '1' in the UNIQUE function argument do?
In the formula UNIQUE(array, [by_col], [exactly_once]), setting the third argument to 1 (or TRUE) forces the function to return only the values that appear exactly once in the dataset, rather than returning a list of all distinct values.
Can I filter duplicates based on multiple columns instead of just the first?
Yes. You can concatenate the columns you want to check within the LET function or adjust the CHOOSECOLS arguments, then perform the XMATCH or MAP logic on that combined criteria array.




