Arrayformula 在 Google 工作表中查找条件的下一个值
Arrayformula to find next value for criteria in Google Sheets
我的工作表中有“表单回复”选项卡,我在其中整理包含起始日期时间戳、编号和姓名的信息。我想创建一个 arrayformula,它将用 datetimestamp 填充最后一列,作为数据集中的下一个名称条目。我想避免提交完成日期时间戳的需要。
我试过了
=ARRAYFORMULA(if(A:A="","",vlookup(C:C,{C2:C20,A2:A20},2,false)))
希望 arrayformula 会在填充更多行时更改搜索范围,但事实并非如此。
它必须是第一行的数组公式,不能使用单个公式并复制和粘贴它,因为它的表单响应会为每个答案添加行
Now
+---------------------+--------------+--------+
| Timestamp | Group number | Picker |
+---------------------+--------------+--------+
| 29/01/2020 21:31:45 | 3001 | Ben |
| 30/01/2020 19:42:20 | 3002 | Ben |
| 30/01/2020 20:04:51 | 3006 | Jon |
| 30/01/2020 20:05:08 | 3018 | Jon |
| 30/01/2020 22:31:45 | 3019 | Ben |
| 31/01/2020 23:31:45 | 3020 | Jon |
| 01/02/2020 21:31:45 | 3021 | Ben |
+---------------------+--------------+--------+
Expected
+---------------------+--------------+--------+---------------------+
| Timestamp | Group number | Picker | ARRAYFORMULA |
+---------------------+--------------+--------+---------------------+
| 29/01/2020 21:31:45 | 3001 | Ben | 30/01/2020 19:42:20 |
| 30/01/2020 19:42:20 | 3002 | Ben | 30/01/2020 22:31:45 |
| 30/01/2020 20:04:51 | 3006 | Jon | 30/01/2020 20:05:08 |
| 30/01/2020 20:05:08 | 3018 | Jon | 31/01/2020 23:31:45 |
| 30/01/2020 22:31:45 | 3019 | Ben | 01/02/2020 21:31:45 |
| 31/01/2020 23:31:45 | 3020 | Jon | |
| 01/02/2020 21:31:45 | 3021 | Ben | |
+---------------------+--------------+--------+---------------------+
尝试:
={""; ARRAYFORMULA(IFNA(VLOOKUP(C2:C, SORT({C2:C, A2:A}, 2, 0), 2, 0)))}
更新:
={"ARRAYFORMULA"; ARRAYFORMULA(IFNA(VLOOKUP(
C2:C&COUNTIFS(C2:C, C2:C, ROW(C2:C), "<="&ROW(C2:C))+1,
FILTER({C2:C&COUNTIFS(C2:C, C2:C, ROW(C2:C), "<="&ROW(C2:C)), A2:A},
ROW(C2:C)-MATCH(C2:C, C2:C, 0)<>1), 2, 0)))}
终于想出了如何使用我为这些类型的查找想到的新技巧来做到这一点。
我知道@player0 已经很好地回答了这个问题!但这也适用于这个问题,如果将来有人偶然发现这个问题,也可以进行其他类似类型的查找:
=ARRAYFORMULA({"Arrayformula";IFERROR(-1/(1/(SUBSTITUTE(LOOKUP(C2:C&9^9-A2:A-0.0001,SORT(C2:C&9^9-A2:A)),C2:C,"")-9^9)))})
我的工作表中有“表单回复”选项卡,我在其中整理包含起始日期时间戳、编号和姓名的信息。我想创建一个 arrayformula,它将用 datetimestamp 填充最后一列,作为数据集中的下一个名称条目。我想避免提交完成日期时间戳的需要。
我试过了
=ARRAYFORMULA(if(A:A="","",vlookup(C:C,{C2:C20,A2:A20},2,false)))
希望 arrayformula 会在填充更多行时更改搜索范围,但事实并非如此。
它必须是第一行的数组公式,不能使用单个公式并复制和粘贴它,因为它的表单响应会为每个答案添加行
Now
+---------------------+--------------+--------+
| Timestamp | Group number | Picker |
+---------------------+--------------+--------+
| 29/01/2020 21:31:45 | 3001 | Ben |
| 30/01/2020 19:42:20 | 3002 | Ben |
| 30/01/2020 20:04:51 | 3006 | Jon |
| 30/01/2020 20:05:08 | 3018 | Jon |
| 30/01/2020 22:31:45 | 3019 | Ben |
| 31/01/2020 23:31:45 | 3020 | Jon |
| 01/02/2020 21:31:45 | 3021 | Ben |
+---------------------+--------------+--------+
Expected
+---------------------+--------------+--------+---------------------+
| Timestamp | Group number | Picker | ARRAYFORMULA |
+---------------------+--------------+--------+---------------------+
| 29/01/2020 21:31:45 | 3001 | Ben | 30/01/2020 19:42:20 |
| 30/01/2020 19:42:20 | 3002 | Ben | 30/01/2020 22:31:45 |
| 30/01/2020 20:04:51 | 3006 | Jon | 30/01/2020 20:05:08 |
| 30/01/2020 20:05:08 | 3018 | Jon | 31/01/2020 23:31:45 |
| 30/01/2020 22:31:45 | 3019 | Ben | 01/02/2020 21:31:45 |
| 31/01/2020 23:31:45 | 3020 | Jon | |
| 01/02/2020 21:31:45 | 3021 | Ben | |
+---------------------+--------------+--------+---------------------+
尝试:
={""; ARRAYFORMULA(IFNA(VLOOKUP(C2:C, SORT({C2:C, A2:A}, 2, 0), 2, 0)))}
更新:
={"ARRAYFORMULA"; ARRAYFORMULA(IFNA(VLOOKUP(
C2:C&COUNTIFS(C2:C, C2:C, ROW(C2:C), "<="&ROW(C2:C))+1,
FILTER({C2:C&COUNTIFS(C2:C, C2:C, ROW(C2:C), "<="&ROW(C2:C)), A2:A},
ROW(C2:C)-MATCH(C2:C, C2:C, 0)<>1), 2, 0)))}
终于想出了如何使用我为这些类型的查找想到的新技巧来做到这一点。
我知道@player0 已经很好地回答了这个问题!但这也适用于这个问题,如果将来有人偶然发现这个问题,也可以进行其他类似类型的查找:
=ARRAYFORMULA({"Arrayformula";IFERROR(-1/(1/(SUBSTITUTE(LOOKUP(C2:C&9^9-A2:A-0.0001,SORT(C2:C&9^9-A2:A)),C2:C,"")-9^9)))})