我正在尝试搜索Data!A2:A来查找Search!A2:A的多个匹配项。找到匹配项后,从Data!B2:B中获取值,并将其以CSV格式放在Search!B2:B中。
此QUERY
有效,但是我想以某种方式仅在列顶部输入一次,而不是手动填写。当我尝试将其包装在ARRAYFORMULA
中时,我只是将第一个结果复制到该列中。
=JOIN(", ",QUERY(Data!$A$2:$B,"SELECT B WHERE A = '"&A2&"'",0))
答案 0 :(得分:1)
=ARRAYFORMULA(REGEXREPLACE(TRIM(IFERROR(VLOOKUP(A2:A, {QUERY(QUERY(Data!A2:B,
"select A,count(A) where A is not null group by A pivot B", 0), "select Col1 offset 1", 0),
TRANSPOSE(QUERY(TRANSPOSE(IF(ISNUMBER(QUERY(QUERY(Data!A2:B,
"select count(A) where A is not null group by A pivot B", 0), "offset 1", 0)),
QUERY(QUERY(Data!A2:B,
"select count(A) where A is not null group by A pivot B", 0), "limit 0", -1)&",", ))
,,999^99))}, 2, 0))), ",$", ))