根据匹配条件查找最后一次出现

时间:2014-11-04 16:03:35

标签: google-sheets

我有一张Google表格,用于为我开发的应用程序运行测试。 电子表格有两张,第一张(“运行”表)我把日期(DD / MM / YYYY格式),测试ID和测试结果:

---------------------------------|
|Date        | test id  | Result
|--------------------------------|
|12/10/2014  | 1        | Passed |
|12/10/2014  | 2        | Passed |
|12/10/2014  | 3        | Passed |
|03/11/2014  | 4        | Passed |
|05/11/2014  | 1        | Failed |    
----------------------------------

在第二张纸上,我希望得到所有测试的列表,以及它们最后一次执行的时间,以及它们的结果。这是“测试”表中的预期输出:

-----------------------------------|
|test id     | Last run   | Result
|----------------------------------|
|1           | 05/11/2014 | Failed |
|2           | 12/10/2014 | Passed |
|3           | 12/10/2014 | Passed |
|4           | 03/11/2014 | Passed |
|5           |            |        |    
------------------------------------

我的问题是我不知道如何进行测试的“最后一次运行”。 我使用了以下公式:

=IF(ISNA(INDEX(Runs!A$3:A$9992, MATCH(A5, Runs!B$3:B$9992, 0))), "", INDEX(Runs!A$3:A$9992, MATCH(A5, Runs!B$3:B$9992, 0)))

但是这只返回测试ID的first match,而不是last one。所以,这是我目前在“测试”表中看到的输出:

-----------------------------------|
|test id     | Last run   | Result
|----------------------------------|
|1           | 12/10/2014 | Passed |
|2           | 12/10/2014 | Passed |
|3           | 12/10/2014 | Passed |
|4           | 03/11/2014 | Passed |
|5           |            |        |    
------------------------------------

有人可以帮我改变公式,让它返回最后一场比赛,比如期望的输出吗?

1 个答案:

答案 0 :(得分:5)

'Test'!B1=max(filter(Runs!A:A,Runs!B:B=A1)) - 找出给定测试ID的最后日期(单元格A1)

'Test'!C1=filter(Runs!C:C,Runs!B:B=A1,Runs!A:A=B1) - 在该日期找出与该测试相对应的结果。

复制其余测试

相关问题