A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
=LET(
Timeframe,XLOOKUP(TODAY(),C:C,C:D,NA(),1),
StartDate,INDEX(Timeframe,1),
EndDate,INDEX(Timeframe,2),
Holidays,B2:B8,
NETWORKDAYS.INTL(StartDate,EndDate,"0000000")-NETWORKDAYS.INTL(StartDate,EndDate,"0000000",Holidays))
So I'm not sure if this is quite what I'm looking for. Let me see if I can explain more thoroughly using the most recent holiday (Memorial Day: 27May2024) as an example:
- Memorial Day (27May2024) is specified in B4
- The "Timeframe Start Date" and "Timeframe End Date" pair containing Memorial Day (15May2024, 28May2024) are specified in C37:D37
- My expectation is that if TODAY() is greater-than or equal to 15May2024 (C37) AND is less-than or equal to 28May2024 (D37), the formula should return "1" due to Memorial Day being within that range.
I tested the formula this morning (28May2024), and not only does it not currently return "1", expectation as stated in 3. above, it does not return "1" until the date specified in "XLOOKUP(search_key" is manually set to a value between 2May2024 and 15May2024 by substituting "DATE(year,month,day)" for "TODAY()", indicating that the formula provided is utilizing the previous two week range prior to the holiday, instead of the two week range containing the holiday.
I believe the correct formula to achieve the expected result is as follows (change in green):
=LET( Timeframe,XLOOKUP(TODAY(),C:C,C:D,NA(),-1),
StartDate,INDEX(Timeframe,1),
EndDate,INDEX(Timeframe,2),
Holidays,B2:B8,
NETWORKDAYS.INTL(StartDate,EndDate,"0000000")-NETWORKDAYS.INTL(StartDate,EndDate,"0000000",Holidays))
Will that be sufficient to correctly handle each instance of the values in Holidays, or are there other changes that need to be made as well?