首页 > 解决方案 > 在数据集中查找多个匹配项,并在一行中返回所有匹配项

问题描述

什么数组公式适用于此?

测试表: 打开

当前数据结构

|   A   |     B      |     C    |
| John  | StartDate1 | EndDate1 |
| Adam  | StartDate3 | EndDate3 |
| John  | StartDate2 | EndDate2 |
| Ted   | StartDate5 | EndDate5 |
| Adam  | StartDate4 | EndDate4 |

预期成绩

|   E   |     F      |     G    |     H      |     I    |
| John  | StartDate1 | EndDate1 | StartDate2 | EndDate2 |
| Adam  | StartDate3 | EndDate3 | StartDate4 | EndDate4 |
| Ted   | StartDate4 | EndDate4 |            |          |

我试过的

=FILTER(B2:C,A2:A = E2)

=TRANSPOSE(FILTER(B2:C,A2:A = E2:E))

=ARRAYFORMULA(VLOOKUP(E2:E,A2:C,{2,3}))

我究竟做错了什么?是否有更好的数组公式可以连续显示与唯一名称匹配的每个开始和结束日期?

谢谢你的帮助!

标签: google-sheetsgoogle-sheets-formulaarray-formulas

解决方案


利用:

=INDEX(SPLIT(FLATTEN(QUERY(QUERY(IF(A3:A="",,{A3:A, "×"&B3:B&"×"&C3:C}), 
 "select max(Col2) where Col2 is not null group by Col2 pivot Col1"),,9^9)), "×"))

在此处输入图像描述


推荐阅读