简体   繁体   English

Excel公式可根据匹配日期和最早日期返回值

[英]Excel Formula that returns a value based on matching and earliest date

I have an Excel spreadsheet with four columns of information. 我有一个包含四列信息的Excel电子表格。

The first column is the primary key of the record. 第一列是记录的主键。 The second column is the edit date of the Closed Date field. 第二列是“截止日期”字段的编辑日期。 The third column is the old value of the Closed Date field The fourth column is the New Value of the Closed Date field 第三列是“截止日期”字段的旧值。第四列是“截止日期”字段的新值。

My need is for a formula that will match the primary key (column A), then look for the earliest date from the edit date (column B, not looking past the matching of the primary key in column A) and then return into column D the value from Old Value (Column D). 我需要一个与主键(A列)匹配的公式,然后从编辑日期开始查找最早的日期(B列,而不是经过A列中主键的匹配),然后返回D列旧值(D列)中的值。

As an example: in the below screen shot I would like to scan the three records, then look only at the three edit dates and then return the 10/31/2015 date because it is a match with the 10/22/15 edit date, which is the earliest date of the three records. 例如:在下面的屏幕快照中,我想扫描三个记录,然后仅查看三个编辑日期,然后返回10/31/2015日期,因为它与10/22/15编辑日期匹配,这是这三个记录的最早日期。

Thanks in advance for the help. 先谢谢您的帮助。

在此处输入图片说明

Try this Array formula: 试试这个数组公式:

=INDEX($D$2:$D$200,MATCH(1,IF(($A$2:$A$200 = "006d000000a3akCAAQ")*(MIN(IF($A$2:$A$200 = "006d000000a3akCAAQ",B$2:$B$200))=B$2:$B$200),1,0),0))

It is an array formula so Ctrl-Shift-Enter to confirm instead of Enter when exiting edit mode. 这是一个数组公式,因此在退出编辑模式时,按住Ctrl-Shift-Enter即可确认,而不是Enter。

You can change the long string for the Id to a cell reference. 您可以将ID的长字符串更改为单元格引用。

With 60k rows, you may want to look into an alternative to the array formula. 对于60k行,您可能需要寻找数组公式的替代方法。 How about a pivot table. 数据透视表如何。 Drag ID and Old Value into the rows area, drag date into the Values and set it to display Min. 将ID和旧值拖到行区域,将日期拖到值中,并将其设置为显示最小值。 Set a value filter on the Old Value to show the Top 10 and configure it to show the bottom 1. 在“旧值”上设置一个值过滤器以显示前10名,并将其配置为显示前1名。

在此处输入图片说明

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

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