How an Excel INDEX MATCH Formula Ranks Unique Products by Sales
Question details
Understand how a formula returns products in descending sales order while checking for previously returned products.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet lists products in column U and sales values in column W of the 'last week sales' sheet. A rank in column B controls which product is returned.
- Observed behavior
- The formula selects the first product with the requested ranked sales value that has not appeared in the earlier output range.
Check that 'last week sales' contains product names in column U and numeric sales values in column W. Put the first sales rank in B128 and make sure C127 does not contain a product that should appear in the results.
Explain the INDEX MATCH formula for ranked products
Use this formula to find the first unlisted product at a specified sales rank and understand when it may return an error.
In B128, enter 1 for the largest sales value, 2 for the second-largest value, and so on.
In C128, enter =INDEX('last week sales'!U:U,MATCH(1,('last week sales'!W:W=LARGE('last week sales'!W:W,B128))*(COUNTIF($C$127:C127,'last week sales'!U:U)=0),0)). In older Excel versions, confirm it with Ctrl+Shift+Enter.
Select C128 and use Formulas > Evaluate Formula to inspect LARGE('last week sales'!W:W,B128). LARGE returns the sales value at the requested row-based rank, and the comparison with column W identifies matching rows.
Continue through Evaluate Formula to inspect COUNTIF($C$127:C127,'last week sales'!U:U)=0. It tests whether each product is absent from the output range above the formula. Multiplying the two tests produces 1 only when both conditions are met.
Enter subsequent ranks in B129 and below, then drag the fill handle from C128 down column C. MATCH finds the first qualifying row, and INDEX returns its product from column U.

Analyze the same product-ranking formula in WPS Spreadsheets
Open the workbook in WPS Spreadsheets and use the INDEX, MATCH, LARGE, and COUNTIF formula to return products at specified sales ranks. Check the results for ties and repeated products, since the formula ranks sales rows rather than aggregated product totals.
- 1. Open the workbook: In WPS Office, open the Excel workbook in WPS Spreadsheets and locate the 'last week sales' sheet.
- 2. Set the first rank: On the output sheet, enter 1 in B128 and check that C127 does not match a product to be returned.
- 3. Enter the formula: In C128, enter =INDEX('last week sales'!U:U,MATCH(1,('last week sales'!W:W=LARGE('last week sales'!W:W,B128))*(COUNTIF($C$127:C127,'last week sales'!U:U)=0),0)). If your WPS version requires array-formula entry, confirm with Ctrl+Shift+Enter.
- 4. Fill and check the results: Enter later ranks in column B and drag the fill handle in column C downward. Check any #N/A result against the source rows for repeated products or tied sales values.

Frequently Asked Questions
What does B128 control in the formula?
B128 supplies the rank to LARGE: 1 requests the largest sales value in column W, 2 requests the second-largest, and so on.
How does the formula avoid returning the same product twice?
COUNTIF checks each product in column U against the output range above the current formula. A product already in that range fails the COUNTIF(...)=0 test.
How are products with tied sales values selected?
LARGE can return the same sales value for consecutive ranks. For each rank, MATCH selects the first source row at that value whose product has not already appeared in the output.
Why does the formula return #N/A even though there are more products?
The requested sales rank may belong to a product already returned, with no other unlisted product at that exact sales value. MATCH cannot skip to a different sales value, so it returns #N/A.
Does the formula rank products by their total sales?
No. LARGE ranks individual values in column W. If a product has multiple rows and you need its combined sales, aggregate those rows by product before ranking.




