Count unique numbers based on date range and another column of data

BradleyS

Active Member
Joined
Oct 28, 2006
Messages
333
Office Version
  1. 2010
Platform
  1. Windows
I have the following code in F5 that looks at the EVENT date and checks if each row is in the date range (F:G), then counts each unique ID number and this works great.

However, I now want to add another check to this, which is if the "check days" (D) is >=5 it should ignore that row (ID) (or <5 it should count it) the same as the date period

I have tried adding ,D2:D5, "<5" to the COUNTIFS criteria but I get a #DIV/0 error or it decimalises the count.
How can I add in the extra check, so it checks the date period and days are <5, then counts the unique IDs?



Excel 2010
ABCDEFG
1IDDATEEVENTCHECK (days)fromto
22344513/10/201814/10/2018101/10/201831/12/2018
3314/10/201815/11/201832
4315/10/201821/10/20186Quarter_ID_COUNT
5316/10/201820/10/201842
NEO1
Cell Formulas
RangeFormula
D2=DATEDIF(B2,C2,"d")
F5{=SUMPRODUCT(IF((C2:C5<=G2)*(C2:C5>=F2), 1/COUNTIFS(C2:C5, "<="&G2, C2:C5, ">="&F2, A2:A5, A2:A5), 0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try one of these array formulas that must be entered with CTRL-SHIFT-ENTER.
Formula in F5 will work if ID column is either text or numeric. Formula in F7 is shorter, but will only work if ID column is numeric.
Excel Workbook
ABCDEFG
1IDDATEEVENTCHECK (days)fromto
22344510/13/201810/14/2018110/1/201812/31/2018
3310/14/201811/15/201832
4310/15/201810/21/20186Quarter_ID_COUNT
5310/16/201810/20/201842if ID text
6
72if ID numeric
Sheet
 
Upvote 0
Solution

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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