SOLVED

Formula to check if date range falls within another date range

Copper Contributor

I am trying to determine if a date range falls within another date range for a specific ID. 

Example: 

Table1

IDStart DateEnd Date
110/9/202211/19/2022
22/12/20233/11/2023

Table2

IDStart DateEnd DateValue
110/10/202211/10/2022Leave
25/5/20245/21/2024Leave

Expected Result

IDResult
1Leave
2(blank)
5 Replies

@TCatron18 Try the following formula. Download the attached file.

 

=MAP(A8:A9,LAMBDA(x,IF(COUNTIFS(F2:F10,x,G2:G10,">="&XLOOKUP(x,A2:A5,B2:B5),H2:H10,"<="&XLOOKUP(x,A2:A5,C2:C5))>0,"Leave","")))

 

Harun24HR_0-1727320157122.png

 

 

 

@Harun24HR It seems to work for some but not working for all. I'm not able to attach any documents here yet, but I'll include some screenshots. The highlighted columns are where the formulas are and for the highlighted row/cells I would expect the value to be 'Leave' based on the data in the Leave tab. 

TCatron18_0-1727365175161.png

TCatron18_2-1727365274457.png

Formula in my 'CHECK' columns: 

=MAP(A2:A2106,LAMBDA(x,IF(COUNTIFS(Leave!A2:A44850,x,Leave!B2:B44850,">="&XLOOKUP(x,Data!A2:A2106,Data!C2:C2106),Leave!C2:C44850,"<="&XLOOKUP(x,Data!A2:A2106,Data!D2:D2106))>0,"Leave","")))

 

 

Would you please share the sample file via google-drive or onedrive? Please show your desired output in sample file.

@Harun24HR Here is a link to the document https://docs.google.com/spreadsheets/d/1-sDskQ3eqWqT6xYlmohjm7KdsBJvupyg/edit?usp=sharing&ouid=11319...  

 

I've only done a handful of expected results in this since the dataset is so large, but the orange highlighted rows should be showing 'Leave' in the CHECK# columns. 

best response confirmed by TCatron18 (Copper Contributor)
Solution
I was able to find a solution that provided what I needed.
=IF(COUNTIFS('Leave'!$A$2:$A$44850,"="&'Data'!$A2,'Leave!$B$2:$B$44850,"<="&'Data'!C2,'Leave'!$C$2:$C$44850,">="&'Data'!D2),"Leave","")
1 best response

Accepted Solutions
best response confirmed by TCatron18 (Copper Contributor)
Solution
I was able to find a solution that provided what I needed.
=IF(COUNTIFS('Leave'!$A$2:$A$44850,"="&'Data'!$A2,'Leave!$B$2:$B$44850,"<="&'Data'!C2,'Leave'!$C$2:$C$44850,">="&'Data'!D2),"Leave","")

View solution in original post