Counting number of date occurrences in a rolling 3 month

Wyrdstone

New Member
Joined
Feb 24, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am fairly new to Excel and hoping someone can give me some advice on how to get a formula to work. I have been scratching my head for hours!

I am thinking a COUNTIFS formula would be the most appropriate.

I have column A which contains a fault code (e.g. KPT1.1, KPT1.2, KPT1.3 etc), column B which contains the date the fault occurred, and column C which contains a numerical value.

I need to create column D which counts how many times the fault code occurred in the last rolling 3 months with a numerical value higher than 0.

I am mainly struggle how to work out how to count the date occurrences in the COUNTIFS formula. something along the lines of:

=COUNTIFS(B:B,"<="&B6, B:B,">="&EDATE(B6,-3)) this obviously returns the wrong number (i feel like I'm halfway there!). I feel if i can get my head round this bit i should be able to sort the other parts of the formula.

Here is hoping someone can help.

Thank you very much.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
do you want the same day 3months ago
=COUNTIFS($B$2:B2,"<="&B2,$B$2:B2,">="&DATE(YEAR(B2),MONTH(B2)-3,DAY(B2)))

or just to the end or begining of the month

so if its the 2/month - only go back to 2/month - see the highlighted cell and different

then add the other criteria
not sure what
with a numerical value higher than 0.
means

Various.xlsx
BCD
1
29/1/211
310/1/212
411/1/213
512/2/213
61/1/224
72/1/224
83/1/224
94/1/224
105/1/224
116/1/224
127/1/224
138/1/224
149/1/224
1510/1/224
1611/1/224
1712/1/224
181/1/234
192/1/234
203/1/234
Sheet5
Cell Formulas
RangeFormula
D2:D20D2=COUNTIFS($B$2:B2,"<="&B2,$B$2:B2,">="&DATE(YEAR(B2),MONTH(B2)-3,DAY(B2)))
 
Last edited:
Upvote 0
Various.xlsx
ABCD
1
2kpt1.19/1/210
3kpt1.210/1/210
4kpt1.311/1/210
5kpt1.112/2/2111
6kpt1.21/1/220
7kpt1.32/1/220
8kpt1.13/1/221
9kpt1.24/1/220
10kpt1.35/1/220
11kpt1.16/1/220
12kpt1.27/1/220
13kpt1.38/1/2231
14kpt1.19/1/220
15kpt1.210/1/220
16kpt1.311/1/221
17kpt1.112/1/220
18kpt1.21/1/230
19kpt1.32/1/230
20kpt1.13/1/230
Sheet5
Cell Formulas
RangeFormula
D2:D20D2=COUNTIFS($B$2:$B$20,"<="&B2,$B$2:$B$20,">="&DATE(YEAR(B2),MONTH(B2)-3,DAY(B2)),$A$2:$A$20,A2,$C$2:$C$20,">"&0)
 
Upvote 0
Thank you so much! it worked like a dream :)

I can follow your formula and see where i went horribly wrong! Just to work the rest out now :)

Thanks again, you have saved my sanity.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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