简体   繁体   English

Google 表格:如何在 Google 表格公式中找到给定数据集(日期-值对)的最高值以及日期?

[英]Google Sheet: How to find Highest Value along with the date for given set of data(date-value pair) in Google Sheet Formula?

I have below data in date-value pair format in Google Sheet:我在 Google 表格中有以下日期值对格式的数据:

Date日期 Value价值
1/8/2021 2021 年 1 月 8 日 1301.85 1301.85
1/11/2021 2021 年 1 月 11 日 1303.9 1303.9
1/12/2021 2021 年 1 月 12 日 1320.05 1320.05
1/13/2021 2021 年 1 月 13 日 1291.55 1291.55
1/14/2021 2021 年 1 月 14 日 1287.45 1287.45
1/15/2021 2021 年 1 月 15 日 1270 1270

I'm looking for a google sheet formula that will return output: highest value along with its associated date.我正在寻找一个谷歌表格公式,它将返回 output: 最大值及其相关日期。 That means I'm trying to get the output as below: 1/12/2021 1320.05这意味着我正在尝试获取 output 如下: 1/12/2021 1320.05

try this:尝试这个:

=INDEX(SORT(A2:B), 2, 0), 1)

You can also use the SORTN function.您也可以使用SORTN function。
The difference being, by using an INDEX formula you need to re-format the column A result to a date while using SORTN you don't.不同之处在于,通过使用INDEX公式,您需要将A列结果重新格式化为日期,而使用SORTN则不需要。

=SORTN(A2:B,1,0,2,0)

在此处输入图像描述

How the SORTN function in our formula works我们公式中的SORTN function 如何工作

  • 1 is "the number of items to return" (since we need just the max we set it to 1) 1是“要返回的项目数” (因为我们只需要我们将其设置为 1 的最大值)
  • 0 "Shows at most the first n rows" (this is the so called ties_mode, in our case 0) 0 “最多显示前 n 行” (这就是所谓的 ties_mode,在我们的例子中为 0)
  • 2 is "the index of the column containing the values to sort by" which here is the 2nd column 2是“包含要排序的值的列的索引” ,这里是第二列
  • 0 "indicates how to sort the sort_column. TRUE (or 1) sorts in ascending order. FALSE (or 0) sorts in descending order". 0 “表示如何对sort_column进行排序。TRUE (或1)按升序排序。FALSE (或0)按降序排序”。

Another approach:另一种方法:

=index(A2:B,match(max(B2:B),B2:B,0))

在此处输入图像描述

Like this answer , you don't need to reformat the date.这个答案一样,您不需要重新格式化日期。

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

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