I am a bit confused myself as to whether the request is for the date or the number of days, so I put dates in columns E:G and number of days in columns I:K.
Column H is a helper column populated using: =SUMIFS(D$2:D2,A$2:A2,A2)
Columns E:G are populated using:
Formula:
=IFERROR(INDEX($B$2:$B$82,MATCH(INDEX($H$2:$H$82,AGGREGATE(15,6,(ROW($H$2:$H$82)-ROW($H$1))/($A$2:$A$82=$A2)/($H$2:$H$82-IF($A1=$A2,$H1,0)>=E$1),1)),$H$2:$H$82,0)),"N/A")
Columns I:K are populated using: =IF(E2="N/A","N/A",E2-$B2)
Let us know if you have any questions.
Bookmarks