接着这个问题 Turning formula into ArrayFormula
我未能明确表明值单元格可能还包含CSV格式的多个值。我尝试将其调整为:
=ARRAYFORMULA(IF(LEN(A4:A), IFERROR(VLOOKUP(SPLIT(A4:A,","),
QUERY(TRIM(TRANSPOSE(SPLIT($B$1, ","))),
"select Col1,count(Col1) group by Col1", 0), 2, 0), 0), ))
但是没有运气。测试表在这里。 https://docs.google.com/spreadsheets/d/12xATTwuc-e6kXn_OF2Uibg6EgtSGbInI6Q_-vueknXg/edit#gid=0
我的原始公式位于B4
中,但可以复制,这是我想要避免的。
答案 0 :(得分:0)
=ARRAYFORMULA(IFERROR(VLOOKUP(A4:A, QUERY({QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(
QUERY(TRANSPOSE(QUERY(TRANSPOSE(IF(LEN(A4:A), "♠"&A4:A&"♦"&TRIM(IFERROR(
SPLIT(A4:A, ","))), )), , 999^99)), , 999^99), "♠")), "♦")), "select Col1", 0),
ARRAY_CONSTRAIN(IFERROR(VLOOKUP(QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(
QUERY(TRANSPOSE(IF(LEN(A4:A), "♠"&A4:A&"♦"&TRIM(IFERROR(SPLIT(A4:A, ","))), ))
, , 999^99)), , 999^99), "♠")), "♦")), "select Col2", 0), QUERY(IFERROR(VLOOKUP(
QUERY(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IF(LEN(A4:A),
"♠"&A4:A&"♦"&TRIM(IFERROR(SPLIT(A4:A, ","))), )), , 999^99)), , 999^99), "♠")), "♦")),
"select Col2", 0), QUERY(TRIM(TRANSPOSE(SPLIT(B1, ","))),
"select Col1,count(Col1) group by Col1", 0), {1, 2}, 0)),
"select Col1,sum(Col2) group by Col1", 0), 2, 0), 0), COUNTA(QUERY(TRIM(SPLIT(
TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IF(LEN(A4:A),
"♠"&A4:A&"♦"&TRIM(IFERROR(SPLIT(A4:A, ","))), )), , 999^99)), , 999^99), "♠")), "♦")),
"select Col1", 0)), 1)}, "select Col1,sum(Col2) group by Col1" ,0), 2, 0)))