How to Return Categories Based on Matching Conditions Across Excel Columns
Question details
The user needs to extract and list specific category headers from a dataset when one row has a zero value and another corresponding row has a non-zero value.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Creating a dynamic list of category names based on cross-row conditional matching across multiple columns.
- Observed behavior
- The goal is to dynamically output the exact matching headers into a list without manually searching through the columns, using a combined array formula.
Ensure that your condition rows and your category header row span the exact same number of columns to prevent index mismatch errors.
Extract Headers Using the INDEX, SMALL, and IF Array Formula
Use a combined array formula to check your multiple row conditions and iteratively return the matching headers from the target range.
This method combines INDEX, SMALL, IF, COLUMN, and ROW functions to evaluate multiple criteria arrays simultaneously. It identifies the relative column positions where both conditions are met, and returns the corresponding column headers one by one as you drag the formula down.
Click on the cell (for example, A8) where you want the first matching category header to be displayed.
Type the formula: =IFERROR(INDEX($B$2:$K$2,SMALL(IF(($B$4:$K$4=0)*($B$6:$K$6<>0),COLUMN($B:$K)-1),ROW($A1))),"") and adjust the ranges if your data is located elsewhere.
If you are using an older version of Excel, you must press Ctrl + Shift + Enter to confirm the formula. In newer versions (like Microsoft 365), you can just press Enter.
Click the bottom-right corner of the cell containing the formula and drag the fill handle down to list all other matching categories until blank cells appear.

Efficiently Execute Complex Array Formulas in WPS Office
WPS Spreadsheet perfectly handles dynamic and legacy array formulas, making it incredibly easy to extract specific categories based on multi-row conditional logic without system lag.
- 1. Open your dataset in WPS: Launch WPS Spreadsheet and open your workbook containing the category and condition rows.
- 2. Enter the formula: Click the target destination cell and paste the provided INDEX-SMALL-IF formula.
- 3. Apply the array calculation: Press Ctrl+Shift+Enter to calculate the array and seamlessly drag the bottom-right fill handle down to extract all matching results.

Frequently Asked Questions
Why is the formula returning empty cells instead of the expected categories?
You may have pressed only 'Enter' instead of 'Ctrl+Shift+Enter'. In non-dynamic array versions of Excel or Spreadsheet applications, array formulas must be confirmed with 'Ctrl+Shift+Enter' to correctly evaluate multiple criteria simultaneously.
How can I modify this formula to check for different conditions?
You can change the logic inside the IF function. For example, instead of ($B$4:$K$4=0)*($B$6:$K$6<>0), you could use ($B$4:$K$4>10)*($B$6:$K$6="Yes") to check for values greater than 10 in the first row and the word 'Yes' in the second row.
What is the purpose of the IFERROR function here?
The IFERROR function prevents the formula from displaying an error (like #NUM!) when you drag the formula down past the total number of matching categories. It outputs a blank cell ("") instead.




