How to Find the Top-Selling Product by Subcategory in Excel
Question details
The user needs a method to identify and return the product with the highest sales volume within specific subcategories, including the ability to handle tied results.

- Product
- Excel / WPS Spreadsheet
- Device & OS
- not provided
- Scenario
- Analyzing a sales worksheet to determine the best-performing products grouped by subcategory.
- Observed behavior
- The goal is to dynamically extract the exact product codes with the maximum units sold for a given subcategory entered in a specific cell.
Ensure your sales data is organized in clear columns (e.g., Column A for Product Code, Column B for Subcategory, and Column C for Units Sold) and check your spreadsheet software version, as modern functions like FILTER and MAXIFS require Microsoft 365, Excel 2019+, or the latest WPS Office.
Use Modern Dynamic Array Formulas (Recommended)
Combine MAXIFS, FILTER, and TEXTJOIN to quickly find the highest sales and return the corresponding product codes, seamlessly handling multiple tied products in one cell.
This is the most efficient method for modern spreadsheet software. It dynamically calculates the maximum value for the specified subcategory and filters the product list to match that maximum value.
First, find the maximum units sold for the target subcategory (e.g., entered in F4) using the formula: =MAXIFS($C$4:$C$11,$B$4:$B$11,F4).
Use the FILTER function to extract the product codes where both the subcategory matches F4 and the sales match the maximum value calculated in the previous step.
Wrap the entire formula in TEXTJOIN so that if two or more products have the exact same top sales, they are combined in a single cell separated by commas. The final formula looks like this: =TEXTJOIN(", ",TRUE,FILTER($A$4:$A$11,($B$4:$B$11=F4)*($C$4:$C$11=MAXIFS($C$4:$C$11,$B$4:$B$11,F4)))).

Use Array Formulas for Older Versions
If you are using an older version of Excel that lacks MAXIFS or FILTER functions, you can calculate the maximum value using a traditional array formula.
Use Power Pivot for Large Datasets
For massive data models, Power Pivot DAX measures provide a robust way to calculate top-selling products.
Easily Find Top Data with WPS Spreadsheet
WPS Office Spreadsheet fully supports modern dynamic array functions like FILTER, MAXIFS, and TEXTJOIN. Analyze your sales data, find top-performing products, and effortlessly handle complex data sets.
- 1. Open your sales data: Launch WPS Spreadsheet and open the workbook containing your product codes, subcategories, and sales data.
- 2. Select the output cell: Click on the target cell where you want to display the top-selling product for your specific subcategory.
- 3. Enter the combined formula: Type or paste the TEXTJOIN and FILTER formula: =TEXTJOIN(", ",TRUE,FILTER($A$4:$A$11,($B$4:$B$11=F4)*($C$4:$C$11=MAXIFS($C$4:$C$11,$B$4:$B$11,F4)))).
- 4. View the instant results: Press Enter. WPS Spreadsheet will instantly calculate the maximum sales and display the top-selling products, natively handling any ties by separating them with a comma.

Frequently Asked Questions
What happens if there are multiple top-selling products with the exact same sales volume?
By using the recommended formula that incorporates TEXTJOIN, the spreadsheet will return all tied product codes in the same cell, separated by a comma (or whichever delimiter you specify).
Why does my MAXIFS formula return a #NAME? error?
The #NAME? error typically occurs if you are using an older version of Excel (2016 or earlier) that does not support the MAXIFS function. You can either use traditional array formulas or use a modern spreadsheet software like WPS Office to resolve this.
Can I find the lowest-selling product using this same method?
Yes. You can simply replace the MAXIFS function with the MINIFS function in your formula to extract the products with the lowest units sold for a specific subcategory.




