如何对相似的细胞进行分组并在这些细胞中获得最大值?

时间:2016-09-10 10:48:09

标签: google-sheets google-docs

╔══════╦════════════════════╦══════════╗
║ Name ║        Date        ║  Stage   ║
╠══════╬════════════════════╬══════════╣
║ Dave ║ 4/29/2016 12:15:36 ║ Booking  ║
║ Dave ║ 4/29/2016 17:58:24 ║ Booking  ║
║ Dave ║ 4/29/2016 11:32:59 ║ Costing  ║
║ Dave ║ 4/29/2016 16:52:47 ║ Costing  ║
║ Dave ║ 4/27/2016 16:59:27 ║ Lead     ║
║ Mark ║ 4/22/2016 12:55:22 ║ Booking  ║
║ Mark ║ 4/24/2016 8:00:45  ║ Booking  ║
║ Mark ║ 4/24/2016 10:07:01 ║ Booking  ║
║ Mark ║ 4/24/2016 14:15:30 ║ Booking  ║
║ Mark ║ 4/24/2016 18:55:22 ║ Booking  ║
║ Mark ║ 4/24/2016 21:33:12 ║ Booking  ║
║ Mark ║ 4/20/2016 12:55:22 ║ New      ║
║ Mark ║ 4/23/2016 16:32:22 ║ Planning ║
║ Mark ║ 4/24/2016 9:11:36  ║ Won      ║
║ Mark ║ 4/24/2016 12:55:22 ║ Won      ║
║ Mark ║ 4/24/2016 17:04:02 ║ Won      ║
║ Mark ║ 4/24/2016 19:55:22 ║ Won      ║
║ Mark ║ 4/25/2016 10:19:13 ║ Won      ║
╚══════╩════════════════════╩══════════╝

我在Google电子表格中有上表。我要做的是将重复的阶段分组并返回每组阶段的最大日期。

我知道如何通过这样做来获取所有单元格的最大日期:  =max(arrayformula((B$2:B$19=B2)*(C$2:C$19)))

但是,我想返回每个阶段的最长日期。我希望我的表格如下所示:

╔══════╦════════════════════╦══════════╦════════════════════╗
║ Name ║        Date        ║  Stage   ║      Max Date      ║
╠══════╬════════════════════╬══════════╬════════════════════╣
║ Dave ║ 4/29/2016 12:15:36 ║ Booking  ║ 4/29/2016 17:58:24 ║
║ Dave ║ 4/29/2016 17:58:24 ║ Booking  ║ 4/29/2016 17:58:24 ║
║ Dave ║ 4/29/2016 11:32:59 ║ Costing  ║ 4/29/2016 16:52:47 ║
║ Dave ║ 4/29/2016 16:52:47 ║ Costing  ║ 4/29/2016 16:52:47 ║
║ Dave ║ 4/27/2016 16:59:27 ║ Lead     ║ 4/27/2016 16:59:27 ║
║ Mark ║ 4/22/2016 12:55:22 ║ Booking  ║ 4/24/2016 21:33:12 ║
║ Mark ║ 4/24/2016 8:00:45  ║ Booking  ║ 4/24/2016 21:33:12 ║
║ Mark ║ 4/24/2016 10:07:01 ║ Booking  ║ 4/24/2016 21:33:12 ║
║ Mark ║ 4/24/2016 14:15:30 ║ Booking  ║ 4/24/2016 21:33:12 ║
║ Mark ║ 4/24/2016 18:55:22 ║ Booking  ║ 4/24/2016 21:33:12 ║
║ Mark ║ 4/24/2016 21:33:12 ║ Booking  ║ 4/24/2016 21:33:12 ║
║ Mark ║ 4/20/2016 12:55:22 ║ New      ║ 4/20/2016 12:55:22 ║
║ Mark ║ 4/23/2016 16:32:22 ║ Planning ║ 4/23/2016 16:32:22 ║
║ Mark ║ 4/24/2016 9:11:36  ║ Won      ║ 4/25/2016 10:19:13 ║
║ Mark ║ 4/24/2016 12:55:22 ║ Won      ║ 4/25/2016 10:19:13 ║
║ Mark ║ 4/24/2016 17:04:02 ║ Won      ║ 4/25/2016 10:19:13 ║
║ Mark ║ 4/24/2016 19:55:22 ║ Won      ║ 4/25/2016 10:19:13 ║
║ Mark ║ 4/25/2016 10:19:13 ║ Won      ║ 4/25/2016 10:19:13 ║
╚══════╩════════════════════╩══════════╩════════════════════╝

1 个答案:

答案 0 :(得分:1)

尝试使用查询。在D2中输入并复制公式:

=query($A2:$C19,"select B where A='" & A2 &"' and C='" & C2 &"' order by B desc limit 1 ")

选择B获取日期。其中A ='“& A2&”'限制在单元格A2中的值(名称)。 C2 =对C2中的单元格值做同样的事情。它按日期排序。在这种情况下降序。限制1有效地获得最大日期,因为它只返回一个值。我希望解释一下这个问题。