Returning oldest date and associated cell info from a range dependent on contents of another cell

rrands1

New Member
Joined
Nov 7, 2004
Messages
29
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
For the following data:
1634683346900.png


I am trying to populate a cell with the oldest "Date Out" (Column J) that does not have a corresponding "Date In" (Column K). The intent is to figure out the oldest date out that has not been returned (Date In), and show the "Assigned to" name as a result. I have the following, which works to find the oldest "Date Out" and show the contents of that row's "Assigned To" cell, however I can't figure out how to only check on ones that don't have anything in the "Date In" cell. Here is my formula so far:
=INDEX(I2:I5,MATCH(MIN(K2:K5),K2:K5,0))

So this would return 7/4/2021, however that has a value in column K (meaning it has been returned), so the value I really am after is 8/28/21 because it's the oldest date that has not been returned. Does anyone know how to make that work?


BONUS Q: This finds the oldest date, but I ideally would like the 3 oldest - is there a way to modify the MIN function (or use a different one) to do like MIN -1, MIN -2?


Thank you so much - I appreciate any help!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
If your version of Excel recognizes the FILTER function, this seems to work:
Book1
IJKLM
1Assigned ToDate OutDate inOldest Assigned To w/o Date In
2First Last7/4/20217/20/2021More Name
3More Name8/28/2021
4Another Name9/4/2021
Sheet6
Cell Formulas
RangeFormula
M2M2=INDEX(FILTER(I2:I4,K2:K4=""),MATCH(MIN(J2:J4),J2:J4,0))
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

I ideally would like the 3 oldest -
As with JoeMo's suggestion IF you have MSoft 365 ..

21 10 20.xlsm
IJKLMNO
1Assigned ToDate OutDate inOldest how many:3
2Name 117/04/20214/07/2021
3Name 213/04/202125/04/2021Assigned ToDate Out
4Name 33/01/2021Name 33/01/2021
5Name 428/07/202120/09/2021Name 85/02/2021
6Name 511/05/2021Name 511/05/2021
7Name 612/10/202112/10/2021
8Name 724/06/2021
9Name 85/02/2021
10Name 931/08/202110/10/2021
Oldest Out
Cell Formulas
RangeFormula
N4:O6N4=INDEX(SORTBY(FILTER(I2:J10,K2:K10=""),FILTER(J2:J10,K2:K10="")),SEQUENCE(O1),{1,2})
Dynamic array formulas.
 
Upvote 0
If you do not have 365, or just need it to work in older versions as well, try these

21 10 20.xlsm
IJKLMNO
1Assigned ToDate OutDate inOldest how many:3
2Name 117/04/20214/07/2021
3Name 213/04/202125/04/2021Assigned ToDate Out
4Name 33/01/2021Name 33/01/2021
5Name 428/07/202120/09/2021Name 85/02/2021
6Name 511/05/2021Name 511/05/2021
7Name 612/10/202112/10/2021  
8Name 724/06/2021  
9Name 85/02/2021  
10Name 931/08/202110/10/2021  
Oldest Out (2)
Cell Formulas
RangeFormula
N4:N10N4=IF(O4="","",INDEX(I:I,AGGREGATE(15,6,ROW(I$2:I$10)/((J$2:J$10=O4)*(K$2:K$10="")),COUNTIF(O$4:O4,O4))))
O4:O10O4=IF(ROWS(O$4:O4)>O$1,"",AGGREGATE(15,6,J$2:J$10/(K$2:K$10=0),ROWS(O$4:O4)))
 
Upvote 0
Another Option is with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date Out", type date}, {"Date in", type date}}),
    #"Filtered Rows" = Table.SelectRows(#"Changed Type", each ([Date in] = null)),
    #"Sorted Rows" = Table.Sort(#"Filtered Rows",{{"Date Out", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type),
    #"Filtered Rows1" = Table.SelectRows(#"Added Index", each ([Index] <> 4)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"Date in", "Index"})
in
    #"Removed Columns"

Book6
ABCDEF
1Assigned ToDate OutDate inAssigned ToDate Out
2Name 14/17/20217/4/2021Name 31/3/2021
3Name 24/13/20214/25/2021Name 82/5/2021
4Name 31/3/2021Name 55/11/2021
5Name 47/28/20219/20/2021
6Name 55/11/2021
7Name 610/12/202110/12/2021
8Name 76/24/2021
9Name 82/5/2021
10Name 98/31/202110/10/2021
Sheet1
 
Upvote 0
@Peter_SSs
You are absolutely correct. In the case presented as an example there was only 4 records and I hastily just removed the 4th record. Thanks for posting that correction. You have the eyes of an eagle. :)

Alan
 
Upvote 0
In the case presented as an example there was only 4 records
Of course, that was my sample data, not the OP's. ;)

I am not all that familiar with power Query. So if the number of records required was variable and indicated by a cell value like O1 in my sample data, can PQ easily adapt to any change in that cell value (eg changing that value from 3 to 2)? If so, how does that work?
 
Upvote 0
Simple answer is yes, but it will require a parameter query. This involves a separate table with that value which is then input into the filter instead of hard coding the 3 or some other value.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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