I've been trying to figure this out for hours and have tried lots of ways to get this to work (e.g., Let, Offset, Countifs, Lambda, helper columns, etc.), but can't crack this nut yet.
Here's a sample of the spreadsheet. NOTE: this is greatly simplified. The actual spreadsheet has many class start dates, many different events, and very different class structures.
Each team has multiple classes with different start dates. Each team also has a completely different class structure (different events, different timelines). Tstart=number of days from class start date the event occurs. Duration=number of days the event lasts. The "Class start dates" and "Class structure" sections are given, but the entire "Schedule" section needs to be calculated, and it needs to be a running list as shown.
The process order would be:
If "Class start date" isn't blank, then calculate the class schedule based on that team's class structure. (This part I have, but I'm sure there are better ways to do it than what I have).
Then, check one cell below the previous "Class start date" and repeat the above with the output being placed immediately below the previous output. This is the iteration part I can't figure out.
Dynamic arrays haven't played nice because each team schedule has a different number of rows based on having a different number of events.
Haven't been able to figure out how to use Offset or other functions to iterate within a single formula.
Would sure appreciate any help!!!
Here's the given data in markdown table format.
Team | Class | Class start date | Team | Event | Tstart | Duration | |
---|---|---|---|---|---|---|---|
Yellow | 1 | 1/15/2024 | Yellow | Paperwork | -10 | 2 | |
Blue | 1 | 1/20/2024 | Yellow | Sign in | 0 | 1 | |
Orange | 1 | 1/30/2024 | Yellow | Interviews | 2 | 2 | |
Yellow | 2 | 2/15/2024 | Blue | Paperwork | -8 | 2 | |
Blue | Sign in | 0 | 1 | ||||
Blue | Interviews | 4 | 2 | ||||
Blue | Farewell | 6 | 1 | ||||
Orange | Paperwork | -6 | 1 | ||||
Orange | Sign in | 0 | 1 | ||||
Orange | Meeting | 3 | 1 | ||||
Orange | Interviews | 5 | 1 |
DROP/REDUCE/VSTACK
combo comes to the rescue.=LET(cdata,A2:C5,edata,E2:H12,
DROP(REDUCE("",SEQUENCE(ROWS(cdata)),LAMBDA(rr,r,LET(
ef,FILTER(edata,CHOOSECOLS(edata,1)=INDEX(cdata,r,1)),
a,TAKE(ef,,2),
b,IF(SEQUENCE(ROWS(ef)),INDEX(cdata,r,2)),
c,INDEX(cdata,r,3)+CHOOSECOLS(ef,3),
d,c+CHOOSECOLS(ef,4)-1,
VSTACK(rr,HSTACK(a,b,c,d))))),1))
Edit (Switched Event
and Class
Columns)
=LET(cdata,A2:C5,edata,E2:H12,
DROP(REDUCE("",SEQUENCE(ROWS(cdata)),LAMBDA(rr,r,LET(
ef,FILTER(edata,CHOOSECOLS(edata,1)=INDEX(cdata,r,1)),
a,CHOOSECOLS(ef,1),
b,IF(SEQUENCE(ROWS(ef)),INDEX(cdata,r,2)),
c,CHOOSECOLS(ef,2),
d,INDEX(cdata,r,3)+CHOOSECOLS(ef,3),
e,d+CHOOSECOLS(ef,4)-1,
VSTACK(rr,HSTACK(a,b,c,d,e))))),1))