COUNTIFS using intersection of two date periods

rcarmichael

New Member
Joined
Aug 10, 2012
Messages
29
Office Version
  1. 2016
Platform
  1. Windows
Good afternoon all,
I have two named ranges: StartDate and EndDate
StartDate and EndDate.png


I wish to use a COUNTIFS function to count the instances that the following occurs in a separate table (pictured below):
  • "Source.Name": AU
  • "Item": ProductE5
  • At least 1 day of the above date range between StartDate and EndDate (inclusive) intersects the date range in the table below "Starts On" and "Ends On" (inclusive).
PRICE_SpecialHistory.png


The above result SHOULD be 1, as there are 3 days of crossover (16/11 - 19/11); however I can't find a formula to do this.
Currently, the incorrect formula is :
Excel Formula:
=COUNTIFS('PRICE - Special History.xlsx'!PRICE___Special_History[Source.Name],"AU",
'PRICE - Special History.xlsx'!PRICE___Special_History[Item],[@Product],
'PRICE - Special History.xlsx'!PRICE___Special_History[Starts On],">="&StartDate,
'PRICE - Special History.xlsx'!PRICE___Special_History[Ends On],"<="&EndDate)

Any ideas how I can achieve this?
Sincere regards,
Ryan
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Second suggestion to get faster/better responses: Investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

See if this is the sort of thing you are after. If so you will have to adapt workbooks, table names etc.

rcarmichael.xlsm
ABCDEFGHI
1Source.NameItemSpecialStarts OnEnds OnStart Date
2AUProd 116/11/2023
3AUProd 2End Date
4AUProd 323/11/2023
5AUProd 4
6AUProd 528/05/20199/06/2019Source.NameAU
7AUProd 513/08/20191/09/2019ItemProd 5
8AUProd 5Count1
9AUProd 5
10AUProd 5
11AUProd 5
12AUProd 5
13AUProd 522/08/20233/09/2023
14AUProd 531/10/202319/11/2023
15
16
Sheet1
Cell Formulas
RangeFormula
I8I8=COUNTIFS(Table1[Source.Name],I6,Table1[Item],I7,Table1[Starts On],"<="&EndDate,Table1[Ends On],">="&StartDate)
Named Ranges
NameRefers ToCells
EndDate=Sheet1!$H$4I8
StartDate=Sheet1!$H$2I8
 
Upvote 1
Solution
Good morning @Peter_SSs,
Firstly, thank you for your suggestions; I have updated my Account Details and installed the XL2BB Add-In for future use.
And secondly, thank you - your change in the formula works perfectly!
Sincere regards,
Ryan
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

Thanks also for updating your version details. (y)

In case you have not actually used XL2BB yet it is common that new users find that they cannot initially use it after installation. If that happens to you, first check this post:
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top