Function Problems

Return Unique Top Items in WPS Office Excel When Quantities Are Tied

Jason MillerJason Miller Nov 13, 2026 870 views

Question details

The user needs a formula to return the top four unique item names from a row when purchase quantities are tied, while ignoring zero quantities and leaving unused result cells blank.

How to Return Unique Top Items in WPS Office Excel When Quantities Are Tied
Product
WPS Office Spreadsheet
Device & OS
not provided
Scenario
The user has item names in one row and matching purchase quantities in another row, and wants to extract the top four performers without duplicate names.
Observed behavior
Basic formulas can return duplicate item names when quantities are tied, and unused result cells may not remain blank when fewer than four items qualify.
Before you start

Arrange your item names in a single row and the matching quantities in the row directly below. Make sure the result cells are empty before entering the formula so the spill or copied range does not overlap existing data.

Solution 1Recommended

Use TAKE, SORTBY, and FILTER to Return the Top Four Unique Names

Best for Microsoft 365 and WPS Office versions that support dynamic arrays; this formula filters out zero quantities, sorts descending, and returns only the first four unique names.

Because the item headers are unique, sorting tied quantities does not create duplicate names. The formula returns a spilled horizontal array, so leave the four cells to the right empty.

1
Select the output cell

Click the cell where you want the first top item to appear, for example N2.

2
Enter the dynamic array formula

Type =TAKE(SORTBY(FILTER($B$1:$I$1,$B2:$I2>0,""),FILTER($B2:$I2,$B2:$I2>0,0),-1),,4) and press Enter.

3
Confirm the spilled results

Check that up to four item names appear to the right. If there are fewer than four positive quantities, only the available names are returned and the rest remain blank.

Use TAKE, SORTBY, and FILTER to Return the Top Four Unique Names
Shortest formula: This works without Ctrl+Shift+Enter in dynamic-array versions and automatically leaves unused results blank.
WPS Office formula solution

Return Top Unique Items in WPS Office Spreadsheet with a Simple Formula

Use WPS Office Spreadsheet to filter out zero quantities, sort by quantity, and return the top four unique item names without duplicates. The familiar Excel formulas work in a free, lightweight spreadsheet app with full .xlsx compatibility.

  1. 1. Open your workbook in WPS Office Spreadsheet: Launch WPS Office and open the .xlsx or .xls file that contains the item names and quantities.
  2. 2. Select the output cell: Click the cell where the first result should appear, leaving enough blank cells to the right for up to four returned names.
  3. 3. Enter the top unique items formula: Type =TAKE(SORTBY(FILTER($B$1:$I$1,$B2:$I2>0,""),FILTER($B2:$I2,$B2:$I2>0,0),-1),,4) and press Enter if your WPS version supports dynamic arrays. Otherwise, use the classic INDEX/MATCH array formula.
  4. 4. Check and save the results: Verify that only unique top names appear and unused result cells are blank, then save the workbook in WPS Office or Excel format.
Extract top unique values even when quantities are tied without duplicate namesWorks with Excel formulas including dynamic arrays and classic INDEX/MATCH alternativesFull compatibility with .xlsx, .xls, and .csv filesFree spreadsheet app with a familiar ribbon interface
QA img-9

Frequently Asked Questions

Why does my formula return duplicate item names when quantities are tied?

Some formulas repeatedly match the same largest quantity. Add a COUNTIF condition that excludes previously returned names, or use FILTER with SORTBY and TAKE so each unique header is returned only once.

How do I exclude zero quantities before returning the top items?

In dynamic-array versions, use FILTER($B$1:$I$1,$B2:$I2>0,"") inside the formula. In older versions, include the condition ($B3:$I3>0) in the INDEX/MATCH array formula.

Can I use this formula in older Excel versions without dynamic arrays?

Yes. Use the INDEX, MATCH, LARGE, and COUNTIF array formula and confirm with Ctrl+Shift+Enter. The IFERROR wrapping returns blank cells when no more qualifying names exist.

How do I leave unused result cells blank if there are fewer than four qualifying items?

Dynamic-array formulas return only the available values, so adjacent cells remain empty. Classic array formulas wrap the result in IFERROR to return an empty string when no match is found.

Does WPS Office support the TAKE, SORTBY, and FILTER functions?

Recent versions of WPS Office Spreadsheet support dynamic array functions. If your version does not, use the classic INDEX/MATCH formula and confirm it with Ctrl+Shift+Enter if necessary.