Reputation: 120
I have a sheet that looks like this:
I would like to be able to return all results from row 1 given a criteria from the data in B2:G7. For example, if I wanted "Grass" from the above sheet, the results would be:
I have tried to do this with FILTER, but it requires the condition be limited to one row or column. What would be the best alternative?
Example sheet here: https://docs.google.com/spreadsheets/d/110De2u6mKLT7SOTfaXN6EZVqgD35pEeeog9o5WWn5bs
Upvotes: 0
Views: 1038
Reputation: 9355
I've added a new sheet ("Erik Help") to your sample spreadsheet. Enter a search word in A2. The results will be returned beginning in C2 and filling rightward.
The C2 formula:
=IFERROR(FILTER(Sheet1!B1:G1,ISNUMBER(SEARCH(TRIM(A2),QUERY(Sheet1!B2:G,,ROWS(Sheet1!B2:G))))),"NO MATCHES")
The important piece here is the QUERY
. While most people know that the final parameter of a QUERY
can be set to 0 or 1 to signify how many header rows to return, the actual number of rows that can be returned in the header is not limited to 0 or 1. So if we ask QUERY
to return no selected data in a "Select" clause and yet set the header parameter to the number of data rows, headers for each column wind up being a column-by-column mash-up of the data from each row in each column.
This we can use with FILTER
, as you can see.
Upvotes: 2