Function Problems

How to Return a Category from an X Mark in Excel using INDEX and MATCH

Jason MillerJason Miller Nov 10, 2026 869 views

Question details

The user needs a formula to retrieve a specific column header (category) by looking up a Product ID, identifying the cell marked with an "X" within that product's row, and returning the top-row header name.

How to Return a Category from an X Mark in a Horizontal Excel Assignment
Product
Excel
Device & OS
not provided
Scenario
Categorizing horizontal data assignments where items are identified by unique IDs that span across multiple category columns, marked specifically with an "X".
Observed behavior
The user wants an automated formula instead of manually visually searching for the "X" for each Product ID to identify its category.
Before you start

Make sure your reference table is organized in a clear grid format, with unique Product IDs in the first column and category headings in the top row. Verify that your "X" marks do not contain hidden trailing spaces, as this can cause formula errors.

Solution 1Recommended

Use Nested INDEX and MATCH Functions

This method utilizes nested formulas to accurately find the specific row using the Product ID, locate the "X" horizontally, and return the top-row header as the category.

To solve this, we can structure a formula where the inner functions isolate the specific data row of a product, and the outer functions locate the "X" to match against the header row.

1
Define your data ranges

Identify the key areas within your sheet or a secondary sheet ('Sheet2' in this example). Your category headings should be in '$B$1:$D$1', your data columns '$B:$D', and the product IDs in column '$A:$A'.

2
Write the inner MATCH to find the Product ID row

Use MATCH($A3,'Sheet2'!$A:$A,0) to locate the exact row number where your Product ID is positioned in the lookup table.

3
Retrieve the row data via the inner INDEX

Wrap that MATCH function inside an INDEX function like this: INDEX('Sheet2'!$B:$D, MATCH($A3,'Sheet2'!$A:$A,0), 0) to return all the category cells from that specific row.

4
Locate the "X" and extract the header

Use an outer MATCH to find the position of "X" inside that row: MATCH("X", [inner_index_formula], 0). Finally, nest this entire segment inside a final INDEX looking at the headers: INDEX('Sheet2'!$B$1:$D$1, 1, [outer_match_formula]).

5
Wrap with IFERROR

Complete the formula by handling potential blanks or mismatches with IFERROR. Your final formula in the destination cell will look like this: =IFERROR(INDEX('Sheet2'!$B$1:$D$1,1,MATCH("X",INDEX('Sheet2'!$B:$D,MATCH($A3,'Sheet2'!$A:$A,0),0),0)),"").

Use Nested INDEX and MATCH Functions
Tip: Locking your ranges using absolute cell references (the $ symbol) ensures that the formula continues functioning perfectly when you drag it down.
Advanced Formulas in WPS Spreadsheet

Easily Perform Advanced Data Lookups with WPS Spreadsheet

WPS Spreadsheet provides a fully equipped, user-friendly environment for building and troubleshooting complex nested functions like INDEX and MATCH, allowing you to efficiently process large datasets and horizontal assignments without missing a beat.

  1. 1. Open Your Workbook: Launch WPS Spreadsheet and open the file containing your horizontal Excel assignment data.
  2. 2. Select the Target Cell: Click on the specific cell where you want the resulting category to appear.
  3. 3. Input the Formula: Type the nested =IFERROR(INDEX(...)) formula directly into the formula bar. WPS Spreadsheet will provide tooltip guides to help validate parameter nesting.
  4. 4. Apply Downwards: Press Enter, then click the small square in the bottom-right corner of the cell and drag it down to apply the lookup algorithm to all rows.
Fully compatible with Microsoft Excel formulas and functionsFeatures a deep formula library with robust syntax highlightingProcesses large datasets quickly and without crashingFree and lightweight office alternative for all daily processing tasks
QA img-9

Frequently Asked Questions

What if my table uses checkmarks (✓) instead of "X"?

You can modify easily without changing the core formula structure. Simply replace the "X" within the outer MATCH parameter with the specific symbol used, such as MATCH("✓", ...).

Why does the formula return a blank or an error?

A blank response is typically caused by the IFERROR function triggering because the exact string "X" or the Product ID was not found. Check for trailing or leading spaces residing in the cells containing the "X".

Can I use XLOOKUP for this horizontal lookup instead?

Yes, if you are using an updated version of a spreadsheet processor that supports XLOOKUP, you can nest two XLOOKUP functions to achieve the same result. However, using INDEX and MATCH remains the most backward-compatible method for older software formats.