Return Headers for the First Three Nonzero Values in Excel
Question details
Return the column headers and corresponding values for the first, second, and third qualifying numbers in each row.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet has headers in B1:J1 and numeric data in rows below. The user wants to list qualifying values and their headers in order from left to right.
- Observed behavior
- The desired result is a series of header-and-value pairs for each row, with blank results when fewer qualifying values are available.
Check that your headers are in B1:J1 and your numeric data starts in B2:J2, or adjust the formula ranges to match your sheet. Reserve empty columns K:P for the three header-and-value pairs.
Use INDEX and SMALL to return each positive value and its header
Use paired formulas to list the first three positive numbers in each row and their column headers.
The formulas identify qualifying columns from left to right. They use >0 to match positive numbers; replace >0 with <>0 in both formulas if you also want to include negative numbers.
In K1, M1, and O1, enter 1, 2, and 3, respectively. These numbers identify which qualifying value each pair should return.
Select K2 and enter =IFERROR(INDEX($B$1:$J$1,1,SMALL(IF($B2:$J2>0,COLUMN($B$1:$J$1)-COLUMN($A$1)),K$1)),""). In older Excel versions, confirm it with Ctrl+Shift+Enter; in current Excel versions, press Enter.
Select L2 and enter =IFERROR(INDEX($B2:$J2,1,SMALL(IF($B2:$J2>0,COLUMN($B$1:$J$1)-COLUMN($A$1)),K$1)),""). Confirm it the same way as the formula in K2.
Select K2:L2 and copy the pair to M2:N2 and O2:P2. Then select K2:P2 and drag the fill handle down for the remaining data rows.

Find qualifying values and headers in WPS Spreadsheets
Open your workbook in WPS Spreadsheets and use the same INDEX and SMALL formulas to list positive values and their headers by row.
- 1. Open the workbook: In WPS Spreadsheets, choose Open and select your Excel workbook.
- 2. Set the result positions: Enter 1 in K1, 2 in M1, and 3 in O1, assuming headers are in B1:J1 and data begins in B2:J2.
- 3. Add the formulas: Enter =IFERROR(INDEX($B$1:$J$1,1,SMALL(IF($B2:$J2>0,COLUMN($B$1:$J$1)-COLUMN($A$1)),K$1)),"") in K2. Enter =IFERROR(INDEX($B2:$J2,1,SMALL(IF($B2:$J2>0,COLUMN($B$1:$J$1)-COLUMN($A$1)),K$1)),"") in L2. If your WPS version requires array entry, confirm each formula with Ctrl+Shift+Enter.
- 4. Fill the results: Copy K2:L2 to M2:N2 and O2:P2, then drag K2:P2 down to cover the other rows.

Frequently Asked Questions
How do I include negative numbers as well as positive numbers?
Replace >0 with <>0 in both the header and value formulas. This selects nonzero numbers rather than only positive numbers.
Why are some result cells blank?
The formulas use IFERROR to return an empty string when a row has fewer qualifying values than the position requested in K1, M1, or O1.
Do I need to press Ctrl+Shift+Enter?
Older Excel versions require Ctrl+Shift+Enter for these array formulas. In current Excel versions, enter each formula normally with Enter.
How can I return a fourth qualifying value?
Enter 4 in Q1, then copy the formula pair from O2:P2 to Q2:R2. Copy the new pair down for other rows.




