how to identify row based on max date and alphanumeri field

L

Legacy 109559

Guest
Hi,
I have the following data set where I have three columns: Name, Date and ID.
I am trying to identify the latest date against each name and in some cases where the dates are duplicated (as in case of John, 15/05/15) I want to be able to identify the name against latest date and highest ID value (looking at the numeric part of ID only).

so for John, I want to be able to identify with the help of formula in fourth column that this is the "newest" row to use. This way I can just filter the fourth column and get a unique row for each name with the latest date and highest ID.


I tried using this formula =IF(MAX(IF(A2=$A$2:$AB$11, $B$2:$B$11))=P2, "Newest", "") which works great if only max date was involved but I cannot figure out how to incorporate MAX ID in this formula as well to return "newest" against unique name


Name Date ID
John 15/05/2015 REF-137630
John 15/05/2015 REF-135755
John 04/05/2015 REF-135617
Alan 20/05/2015 REF-138261
Alan 19/05/2015 REF-138242
Alan 18/05/2015 REF-137820
Alan 07/05/2015 REF-136218
Adam17/08/2015 REF-153088
Adam23/06/2015 REF-144667
Adam13/05/2015 REF-137107

Thanks for your help.


KR
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Do the reference numbers always begin with "REF-"? Are they always assigned in order, i.e. a reference number on 15/05/2015 will always be greater than a reference number assigned on 14/05/2015?
 
Upvote 0
Hi Eric,
Yes, the id will always begin with REF- and have the same number of characters.
Correct on second part as well, a reference number assigned to the latest date will be greater than one assigned to date before.
Thanks
KR
 
Upvote 0
Hi

Give this a whirl using control+shift+enter - it basically says "if the date is the max for this person and the ref number is the max for this person, write newest, otherwise don't":

Code:
=IF(B2&RIGHT(C2,6)=MAX(IF($A$2:$A$11=A2,$B$2:$B$11))&MAX(IF($A$2:$A$11=A2,--RIGHT($C$2:$C$11,6))),"Newest","")

This works on two conditions:

1. Your REF column has a 6 digit number which forms the last 6 characters of the cell
2. Your REF number (such as 135617) is unique and is always higher on more recent dates

I can clean the formula up if these aren't the case.

As a general rule, storing a number within a text string causes problems if you then want to perform mathematical operators on that number (like find the maximum value, sum or multiply). A better solution would be to store the number itself (such as 137630) in the column and then have the REF- concatenated separately or something.

Hope that helps

Mackers

Edit: just so you know, when you perform operations that cut cells up (like taking the LEFT() or RIGHT()most characters in a cell) Excel will return you a text string rather than a number. As such, if you want to check that the number is the largest, you will need to coerce the text string back into a number using VALUE() or 0+ or -- (I use --RIGHT() in the above example). This means you can then use MAX() on the data.
 
Last edited:
Upvote 0
Here's a version that should work.

Excel 2010
ABCD
1John15/5/2015REF-137630Newest
2John15/5/2015REF-135755
3John4/5/2015REF-135617
4Alan20/5/2015REF-138261Newest
5Alan19/5/2015REF-138242
6Alan18/5/2015REF-137820
7Alan7/5/2015REF-136218
8Adam17/8/2015REF-153088Newest
9Adam23/6/2015REF-144667
10Adam13/5/2015REF-137107

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet15

Array Formulas
CellFormula
D1{=IFERROR(IF(B1*(MID(C1,5,9)+0)=MAX(IF(A1=$A$1:$A$10,$B$1:$B$10*(MID($C$1:$C$10,5,9)+0),0)),"Newest",""),"")}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



I see Mackers added an option too. Let us know what you did.
 
Upvote 0
A big thanks to both Eric and Mackers for this solution.
I have tried both formulas and they work like a charm.
I am going to go with Eric's recommendation only because its slightly faster.
once again , thanks for all your help.

KR
 
Upvote 0

Forum statistics

Threads
1,216,115
Messages
6,128,923
Members
449,478
Latest member
Davenil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top