Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 使用ARRAYFORMULA从查找表中查找源表中的所有匹配行/值_Google Sheets_Google Sheets Formula_Transpose_Array Formulas_Google Sheets Query - Fatal编程技术网

Google sheets 使用ARRAYFORMULA从查找表中查找源表中的所有匹配行/值

Google sheets 使用ARRAYFORMULA从查找表中查找源表中的所有匹配行/值,google-sheets,google-sheets-formula,transpose,array-formulas,google-sheets-query,Google Sheets,Google Sheets Formula,Transpose,Array Formulas,Google Sheets Query,我有一个这样的源表。如您所见,每个查找值可以有一个或多个结果 | Lookup Value | Result | |--------------|--------| | a | a1 | | a | a2 | | a | a3 | | b | b1 | | b | b2 | | c | c1 | | c

我有一个这样的源表。如您所见,每个
查找值
可以有一个或多个
结果

| Lookup Value | Result |
|--------------|--------|
| a            | a1     |
| a            | a2     |
| a            | a3     |
| b            | b1     |
| b            | b2     |
| c            | c1     |
| c            | c2     |
然后我有一个输入表,如下所示:

| queries | results |         |         |         |         |         |
|---------|---------|---------|---------|---------|---------|---------|
| a       | ...     | ...     | ...     | ...     | ...     | ...     |
| c       | ...     | ...     | ...     | ...     | ...     | ...     |
每行的
应为查找表中的转置值。例如,上表如下所示:

| queries | results |    |    |
|---------|---------|----|----|
| a       | a1      | a2 | a3 |
| c       | c1      | c2 |    |
现在我必须使用多个公式,如:

我试图用一个
数组来代替它,但它似乎不起作用

还有别的办法吗?基本上是从查找表中查找所有匹配的行,然后转置它们?

尝试:

=ARRAYFORMULA(IFERROR(VLOOKUP(D:D, SPLIT(TRANSPOSE(QUERY(TRANSPOSE(IF(ISNUMBER(
 QUERY(QUERY(A:B, "select A,count(A) where A is not null group by A pivot B"), "offset 1", 0)), 
 QUERY(QUERY(A:B, "select A,count(A) where A is not null group by A pivot B"), "limit  0", 1), 
 QUERY(QUERY(A:B, "select A,count(A) where A is not null group by A pivot B"), "offset 1", 0)))
 ,,999^99)), " "), TRANSPOSE(ROW(INDIRECT("A2:A"&COUNTUNIQUE(B:B)))), 0)))

假设您的“查找值”和“结果”数据从A1:B运行(标题在A1和B1中)。假设您的“查询”列表位于D1:D(D1中的标题)中,而“结果”标题位于E1中

根据A:A中任何值在B:B中可能匹配的最大数量,您可以在E2中使用此选项:

=ArrayFormula(IFERROR(VLOOKUP(D2:D,QUERY(FILTER({A2:B,COUNTIFS(A2:A,A2:A,ROW(A2:A),"<="&ROW(A2:A))},A2:A<>""),"Select Col1, MAX(Col2) Group By Col1 Pivot Col3"),SEQUENCE(1,10,2),0)))
=ArrayFormula(IFERROR(VLOOKUP)(D2:D,查询)(过滤器({A2:B,COUNTIFS(A2:A,A2:A,行(A2:A)))