In Google Sheets, I have two columns of data.
The first column is labeled Category, and the second Contents
I want to search Contents for a text string and return Category wherever it is matched.
For example, in the table below, if I search Contents for the phrase amino acids I would expect the formula to return both Proteins and Urea cycle from Category:
| Category | Contents |
|---|---|
| Proteins | amino acids, alpha-helix, beta-sheet, primary structure, secondary structure, tertiary structure |
| Urea cycle | transamination, amino acids, urea, glutamine, glutamate, liver, kidney |
I've tried using the functions INDEX and MATCH but it only matched if the search term was the only text in the cell, as opposed to part of comma-separated values (CSV).
XLOOKUP failed for the same reason
I thought about splitting the CSV into an array using SPLIT but that creates a 2-dimensional array that MATCH doesn't support.
The closest I've gotten is the following formula but it returns the matching Contents instead of the Category:
=FILTER(B:B, REGEXMATCH(B:B, "amino acids"))
Maybe an array formula is required.
How do I return multiple results from Category based on matching text substrings in Contents?