简体   繁体   English

Arrayformula 用于在 Google 表格中查找条件的下一个值

[英]Arrayformula to find next value for criteria in Google Sheets

I have Form Responses tab in my sheets where I collate information containing starting datetimestamp, number and name.我的工作表中有“表单响应”选项卡,我在其中整理包含起始日期时间戳、数字和名称的信息。 I want to create an arrayformula that will fill last column with datetimestamp for the next name entry in the dataset.我想创建一个数组公式,它将用日期时间戳填充数据集中下一个名称条目的最后一列。 I want to avoid the need of submitting finish datetimestamp.我想避免提交完成日期时间戳的需要。

I have tried我试过了

=ARRAYFORMULA(if(A:A="","",vlookup(C:C,{C2:C20,A2:A20},2,false))) 

hoping that arrayformula will change the search range as it fills the further rows but it didn't.希望 arrayformula 会在填充更多行时更改搜索范围,但事实并非如此。

It Has to be arrayformula which will be in the first Row, cant use single formula and copy and paste it because its form response which adds row for every answer它必须是位于第一行的 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    |                     |
+---------------------+--------------+--------+---------------------+

try:尝试:

={""; ARRAYFORMULA(IFNA(VLOOKUP(C2:C, SORT({C2:C, A2:A}, 2, 0), 2, 0)))}

在此处输入图片说明


UPDATE:更新:

={"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)))}

0

Finally figured out how to do this with the new trick I thought of for these types of lookups.终于想出了如何使用我为这些类型的查找想到的新技巧来做到这一点。

I realize @player0 has already answered this perfectly well!, But this should also work for this, and other similar types of lookups if anyone stumbles on this in the future:我意识到@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)))})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM