How to get max date from one column and match with other column in Excel?

吃可爱长大的小学妹 提交于 2019-12-24 10:56:48

问题


I have excel sheet data like below

CustomerNo LoginDate
101        25/05/2012
101        10/05/2012
101        20/05/2012
101        10/04/2012
102        21/05/2012
102        12/04/2012
103        20/05/2012
104        08/04/2012

I want to get last login date match with customer number and result like below.

101   25/05/2012
102   21/05/2012
103   20/05/2012
104   08/04/2012

回答1:


You may use the DMAX function to do this.

First, I am putting CustomerNo in A1 and 08/04/2012 in B9. Then I am naming that range "theTable".

Second, I add A11 and B11 my Criteria, "CustomerNo" and "LoginDate".

Then in A12, I place 101.

Finally I am ready for my DMAX function.

In B12, I place =DMAX(theTable,"LoginDate", A11:A12)

Excel will place 25/05/2012 in B12.




回答2:


You could try a pivot table. This has the nice ability to get the max for all customer numbers at once and can be updated quickly if any of the data changes.

  • Select your nicely-formatted table
  • Insert | Pivot Table
  • Drag CustomerNo to Row Labels
  • Drag LoginDate to Values
  • Change the Value Field Settings (e.g., by right clicking any value in the pivot table) to Summarize by Max



回答3:


There are two ways:

  1. With array function (Press Ctrl + Shift + Enter):

=MAX(IF($A$2:$A$9=C2,$B$2:$B$9))

  1. Regular formula:

=MAX(INDEX(($A$2:$A$9=C2)*($B$2:$B$9),,1))

I personally like the 2nd way better since array function will slow down PC performance for huge data. Anyway, hope this helps.



来源:https://stackoverflow.com/questions/10755207/how-to-get-max-date-from-one-column-and-match-with-other-column-in-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!