Function Problems

How to Return the Column Header for the First Positive Value in a Row in WPS Office Spreadsheets

Emma BrownEmma Brown Nov 13, 2026 869 views

Question details

The user needs a formula that scans each row from left to right, finds the first value greater than zero, and returns that column's header in another column.

How to Return the Column Header for the First Positive Value in a Row
Product
WPS Office Spreadsheets
Device & OS
not provided
Scenario
A user has rows of numeric values with column headers such as years and wants a result column that shows the header of the first value greater than zero in each row.
Observed behavior
The user needs a worksheet formula to identify the first positive cell and return its corresponding header, such as returning 2028 when the first positive value is in column G.
Before you start

Make sure your data has a single header row, for example B1:L1, and that the values to test are in a contiguous range on each data row, such as B2:L2.

Solution 1Recommended

Use XLOOKUP to Return the Header of the First Positive Value

Best for modern WPS Spreadsheets and Microsoft 365/Excel 2021 builds because XLOOKUP keeps the formula short and readable.

XLOOKUP evaluates B2:L2>0 as an array of TRUE/FALSE values, finds the first TRUE, and returns the corresponding header from B$1:L$1.

1
Select the result cell

Open WPS Office Spreadsheets and select cell N2, the first cell in your results column.

2
Enter the XLOOKUP formula

Type =XLOOKUP(TRUE,B2:L2>0,B$1:L$1,"No match") and press Enter.

3
Fill the formula down

Drag the fill handle from N2 down through the remaining rows in your table.

Use XLOOKUP to Return the Header of the First Positive Value
Result: N2 returns the first positive column header, such as 2028, or "No match" when no value is greater than zero.
WPS Spreadsheets Formula Help

Return the First Positive Value’s Header in WPS Office Spreadsheets

Open your workbook in WPS Office Spreadsheets and use the formula shown above. WPS Spreadsheets handles the same lookup formulas and Excel .xlsx files, so you can return the correct header for the first positive value in each row without changing tools.

  1. 1. Open your workbook in WPS Office: Launch WPS Office Spreadsheets and open the .xlsx workbook that contains the header row and data rows.
  2. 2. Select the result cell: Click N2, or the first cell where you want each row's returned header.
  3. 3. Type the formula: Enter =XLOOKUP(TRUE,B2:L2>0,B$1:L$1,"No match") or the classic INDEX/SMALL/IF array formula described above.
  4. 4. Copy it down: Drag the fill handle from N2 through the remaining data rows to populate results.
  5. 5. Review the returned headers: Confirm that rows with a first positive value in column G return 2028 or the matching header.
Directly solves the first-positive-value header lookup with standard spreadsheet formulas.Supports familiar Excel functions such as INDEX, IF, SMALL, FILTER, and XLOOKUP in compatible versions.Free, lightweight Office suite with full Microsoft Excel .xlsx/.xls compatibility for sharing and collaboration.Familiar ribbon and formula bar reduce training time for users moving from Microsoft Excel.
QA img-9

Frequently Asked Questions

Which formula should I use in WPS Office if XLOOKUP is not available?

Use the classic array formula: =INDEX($B$1:$L$1,SMALL(IF($B2:$L2>0,COLUMN($B$1:$L$1)-1),1)). If your WPS build does not treat it as a dynamic array formula, enter it with Ctrl+Shift+Enter.

Can I return the header for the first negative value instead?

Yes. Replace the >0 test with <0. For example: =XLOOKUP(TRUE,B2:L2<0,B$1:L$1,"No match"), or use IF($B2:$L2<0,COLUMN($B$1:$L$1)-1) in the INDEX/SMALL/IF formula.

Why does the INDEX/SMALL/IF formula show #NUM! when no positive values exist?

The formula cannot find a first positive position, so it returns #NUM!. Wrap it with IFERROR to display a custom message: =IFERROR(INDEX($B$1:$L$1,SMALL(IF($B2:$L2>0,COLUMN($B$1:$L$1)-1),1)),"No match").

Does this formula work if my headers are in a column instead of a row?

No, these formulas are designed for a horizontal header row. If your headers are in a column and values are in a row, the formula needs to be transposed using INDEX/MATCH or related functions.