I would like to be able to return [cat,dog] as shown in column B. This is more of a POC, but for the main challenge I am facing, there will be an unknown number of values in cell A1. I'm not sure if there is a way to do this with a vlookup, or if there is a better way to do this.
Vlookup on multiple values in a cell
98 views Asked by aaron At
2
There are 2 answers
0
On
Guessing there could be more then one canine species (dog, dog2, ...) and all should be returned:
= "["
& JOIN(
",",
QUERY(
A3:B11,
"SELECT B
WHERE A MATCHES '^(?:" & JOIN("|", UNIQUE(SPLIT(A1, "[,]"))) & ")$'
ORDER BY B",
0
)
)
& "]"
We just filter out everything that does not match the regular expression ^feline|canine|...$
with QUERY
using MATCHES
and join it with commas.
Regular expression is constructed in this (just unique words joined by |
):
'^(?:" & JOIN("|", UNIQUE(SPLIT(A1, "[,]"))) & ")$'
use: