In A1:C3
, I have sample data, displaying two separate tasks, each with start and end dates. What I am trying to accomplish is an output dynamically displaying all Friday dates between and including the start and end dates each of the two sets of dates. The desired output can be seen in E1:F20
.
I have attempted using sequence formulas, be keep ending up with the same result, as seen here.
Here is one way of doing this:
• Formula used in cell E2
=LET(
_Data, A2:C3,
_Dates, DROP(_Data,,1),
_Max, SEQUENCE(,MAX(_Dates),-1,7),
_Merged, TOCOL(IFS( (_Max>=TAKE(_Dates,,1))*(_Max<=TAKE(_Dates,,-1)),TAKE(_Data,,1)&"|"&_Max),3),
SORT(HSTACK(TEXTBEFORE(_Merged,"|"),--TEXTAFTER(_Merged,"|")),2))
Updated as per OP's Comments:
Is there a way to account for end dates spilling in the following week, that do not land on a Friday ie. if all sample date remained the same, except for cell C3, and that date was Tue, 4/30/24 instead, but the date represented in the dynamic list automatically rounded up to that week's Friday date(5/3/24)?
=LET(
_Data, A2:C3,
_Dates, DROP(_Data,,1),
_Max, SEQUENCE(,MAX(_Dates),-1,7),
_Start, TAKE(_Dates,,1),
_End, TAKE(_Dates,,-1),
_Merged, UNIQUE(TOCOL(IFS( (_Max>=_Start)*(_Max<=_End),TAKE(_Data,,1)&"|"&_Max,
WEEKDAY(_End,2)<>5,TAKE(_Data,,1)&"|"&_End,1,NA()),3)),
SORT(HSTACK(TEXTBEFORE(_Merged,"|"),--TEXTAFTER(_Merged,"|")),2))
Even the following formula should work as intended :
=LET(
_Data, A2:C3,
_Dates, DROP(_Data,,1),
_Start, TAKE(_Dates,,1),
_End, TAKE(_Dates,,-1),
_Max, SEQUENCE(,MAX(_Dates),-1,7),
_Merged, UNIQUE(TOCOL(IFS( (_Max>=_Start)*(_Max<=_End), TAKE(_Data,,1)&"|"&_Max,
WEEKDAY(_End,2)<>5, TAKE(_Data,,1)&"|"&EOMONTH(SEQUENCE(,MAX(_End-_Start+1),TAKE(_End,1)),-1),
1,NA()),3)),
_TaskDates, --TEXTAFTER(_Merged,"|"),
SORT(HSTACK(TEXTBEFORE(_Merged,"|"),_TaskDates,TEXT(_TaskDates,"ddd")),2))