问题
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
toRow Labels
- Drag
LoginDate
toValues
- Change the
Value Field Settings
(e.g., by right clicking any value in the pivot table) toSummarize by
Max
回答3:
There are two ways:
- With array function (Press
Ctrl + Shift + Enter
):
=MAX(IF($A$2:$A$9=C2,$B$2:$B$9))
- 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