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!
 
@Peter_SSs

To test my explanation I added a few more records to your sample then built a parameter query into the Mcode I earlier provided.

Book9
ABCDEFG
1Assigned ToDate OutDate inOldest how many:
2Name 14/17/20217/4/20213
3Name 24/13/20214/25/2021
4Name 31/3/2021Assigned ToDate Out
5Name 47/28/20219/20/2021Name 31/3/2021
6Name 55/11/2021Name 82/5/2021
7Name 610/12/202110/12/2021Name103/1/2021
8Name 76/24/2021
9Name 82/5/2021
10Name 98/31/202110/10/2021
11Name103/1/2021
12Name113/15/20213/17/2021
Sheet1


The code for the parameter query called "Oldest" is:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Oldest how many:" = Source{0}[#"Oldest how many:"]
in
    #"Oldest how many:"
and the code where the parameter is now placed into the original query is:
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] < Oldest +1)), 
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"Date in", "Index"})
in
    #"Removed Columns"
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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)))
@Peter_SSs (and all who replied) - thank you *so much* for your help on this - I really appreciate it! Peter's code here is the closest to what I need (I am on o365, and have updated my profile accordingly). I am running into a couple of things, and wondered if there is a way to account for it?


1. I have some blank rows in between the sections of data, and that is causing the formula to not evaluate anything after the first blank row. Is it possible to have this ignore those blank rows?

2. I also have some cells in column J (Date Out) that are empty, and this also causes an issue (Date Out in column O shows 1/0/1900) - it is possible to have the formula ignore those blank cells?


Thank you again - I appreciate it!
 
Upvote 0
Thanks for updating your profile. (y)

I'm confused by the fact that you have 365 but you have quoted my post that was for other versions as well, and apparently seem to be using those formulas, not the 365 formulas.
From what I can understand of your description, the 365 formulas work as expected. Is there something wrong with my sample data or results?

rrands.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 45/04/2021Name 115/02/2021
6Name 45/04/2021
7Name 628/07/202120/09/2021
8Name 7
9Name 812/10/202112/10/2021
10
11
12Name 9
13Name 1024/06/2021
14Name 115/02/2021
15Name 1231/08/202110/10/2021
Oldest Out
Cell Formulas
RangeFormula
N4:O6N4=INDEX(SORTBY(FILTER(I2:J15,K2:K15=""),FILTER(J2:J15,K2:K15="")),SEQUENCE(O1),{1,2})
Dynamic array formulas.
 
Upvote 0
Solution
Thanks for updating your profile. (y)

I'm confused by the fact that you have 365 but you have quoted my post that was for other versions as well, and apparently seem to be using those formulas, not the 365 formulas.
From what I can understand of your description, the 365 formulas work as expected. Is there something wrong with my sample data or results?

rrands.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 45/04/2021Name 115/02/2021
6Name 45/04/2021
7Name 628/07/202120/09/2021
8Name 7
9Name 812/10/202112/10/2021
10
11
12Name 9
13Name 1024/06/2021
14Name 115/02/2021
15Name 1231/08/202110/10/2021
Oldest Out
Cell Formulas
RangeFormula
N4:O6N4=INDEX(SORTBY(FILTER(I2:J15,K2:K15=""),FILTER(J2:J15,K2:K15="")),SEQUENCE(O1),{1,2})
Dynamic array formulas.
This worked - THANK YOU, THANK YOU, THANK YOU!!

I appreciate it very much - I learned a ton just from this post - some functions I was not aware of before, so thanks for that, too!

-randy
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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