COUNTIFS using MONTH and YEAR references

redhots4

Board Regular
Joined
Aug 30, 2004
Messages
139
Office Version
  1. 365
Platform
  1. MacOS
I have a long list of dates. In another tab, I have a list of Month / Year combos (1/1/24 displayed as Jan-24, 2/1/24 displayed as Feb-24, etc) ranging from Jan-22 to Mar-25. I want a formula that will look at the list of dates and return the count of dates that fall within each month. See attached for a sample of the data. Thanks in advance!

Case Load 20250309_SHAWN VER.xlsx
ABCDE
1Date ReceivedMonthCount
21/16/24Jan-243<-- Count the number of dates in colum A that are in Jan 2024
31/17/24Feb-241
41/18/24Mar-2412
52/25/24Apr-248
63/10/24May-247
73/21/24Jun-2410
83/29/24Jul-2413
94/3/24Aug-245
104/6/24Sep-2420
114/23/24Oct-2417
126/5/24Nov-2415
136/10/24Dec-2414
146/13/24Jan-2511
156/14/24Feb-2522
167/10/24
177/10/24
188/8/24
198/12/24
208/12/24
218/23/24
229/10/24
239/15/24
2410/8/24
2510/16/24
2611/10/24
2711/15/24
2811/16/24
2911/21/24
3011/28/24
3112/15/24
3212/22/24
331/7/25
341/20/25
351/26/25
Sheet1
 
Thank you for the replies, everyone. I'm surprised there isn't a way to simply look at the year & month in Col C, then go to the days in Col A and count the number dates that have the same year and month.
 
Upvote 0
Thank you for the replies, everyone. I'm surprised there isn't a way to simply look at the year & month in Col C, then go to the days in Col A and count the number dates that have the same year and month.
You could, but Alex's formula is actually simpler than that. What you are describing actually involves having to use two criteria (check month and year) where Alex's just checks the date.
And I believe since you would have to do the computation to pull out month and year BOTH to your criteria AND the all data you are checking, I think you would not be able use COUNTIFS, but would have to use a more complex SUMPRODUCT (which is not as intuitive to understand).

It is helpful to really understand how Excel stores dates. It actually stores dates as numbers, specifically the number of days since 1/0/1900.
If you enter any valid date in Excel, and change the format to "General", you will see the date as Excel really sees the date.
Working with this Integer allows you to do lots of mathematic computations on the dates more easily (as opposed having to parse out the month and year separately and check each one).
 
Upvote 0
srt.xlsm
ABCD
1Date ReceivedMonthCount
201/16/24Jan-243
301/17/24Feb-241
401/18/24Mar-243
502/25/24Apr-243
603/10/24Jun-244
703/21/24Jul-242
803/29/24Aug-244
904/03/24Sep-242
1004/06/24Oct-242
1104/23/24Nov-245
1206/05/24Dec-242
1306/10/24Jan-258
1406/13/24Feb-253
1506/14/24  
1607/10/24  
1707/10/24  
1808/08/24  
1908/12/24  
2008/12/24  
2108/23/24  
2209/10/24  
2309/15/24  
2410/08/24  
2510/16/24  
2611/10/24  
2711/15/24  
2811/16/24  
2911/21/24  
3011/28/24  
3112/15/24  
3212/22/24  
3301/07/25  
3401/20/25  
3501/26/25  
3601/27/25  
3701/28/25  
3801/29/25  
3901/30/25  
4001/31/25  
4102/01/25  
4202/02/25  
4302/03/25  
Sheet5
Cell Formulas
RangeFormula
C2:C43C2=IFERROR(TEXT(AGGREGATE(15,6,$A$2:$A$200/(ROW($A$2:$A$200)-ROW($A$2)+1=MATCH(TEXT($A$2:$A$200,"[$-en-US]mmm-yy;@"),TEXT($A$2:$A$200,"[$-en-US]mmm-yy;@"),0)),ROW(A2:A200)),"[$-en-US]mmm-yy;@"),"")
D2:D43D2=SUM(--($C2=TEXT($A$2:$A$200,"[$-en-US]mmm-yy;@")))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
With Excel 365, build your own function see example or use sum or sumproduct.

T202503a.xlsm
ABCDEFG
1Date mmm-yyCountDate mmm-yyCountCustom format mmm-yyCountCount
2Jan-243Jan-243Jan-2433
3Feb-241Feb-241Feb-2411
4Mar-243Mar-243Mar-2433
5Apr-243Apr-243Apr-2433
6Jun-244Jun-244May-2400
7Jul-242Jul-242Jun-2444
8Aug-244Aug-244Jul-2422
9Sep-242Sep-242Aug-2444
10Oct-242Oct-242Sep-2422
11Nov-245Nov-245Oct-2422
12Dec-242Dec-242Nov-2455
13Jan-253Jan-253Dec-2422
14Jan-2533
1534343434
16
2g
Cell Formulas
RangeFormula
A1:B13A1=NumDatesByMonth(DataDates!A.:.A)
C1:D13C1=NumDatesByMonth(DataDates!A1.:.A1000)
F2:F14F2=SUM(--(TEXT(DataDates!A2:A35,"mmm-yy")=TEXT(E2,"mmm-yy")))
G2:G14G2=SUMPRODUCT(--(TEXT(DataDates!A2:A35,"mmm-yy")=TEXT(E2,"mmm-yy")))
F15:G15,D15,B15F15=SUM(F2:F14)
Dynamic array formulas.
Lambda Functions
NameFormula
NumDatesByMonth=LAMBDA(rngDates,LET(x,rngDates,a,LET(d,x-DAY(x)+1,GROUPBY(d,d,COUNT,1,0)),VSTACK({"Date mmm-yy","Count"},HSTACK(TEXT(INDEX(a,,1),"mmm-yy"),INDEX(a,,2)))))
 
Upvote 0

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