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
 
Not sure if column C is entered as text, or as a date with a custom format. But the typical way is to count the numbers between the first and last days of the month.
See here: Count cells between dates
 
Upvote 0
Note that when I copy paste your data into my Excel, it shows that the value entered in cell C2 are formatted as "dd-mmm".
So, if I look in the formula bar, it shows me the entry is actually for the date 1/24/2025, not for 2024.

1741813035317.png


If you click on cell C2, and look in the formula bar, what does it show you?
What if you temporarily change the format of that cell to mm/dd/yyyy? What does that show you?

Note that all valid dates in Excel must have a month, day, and year component, though you can custom format it to just show you the pieces you want to see.
But Excel calculations run off the REAL underlying values, not the formatted ones.
 
Upvote 0
I understand the date formatting. I want a formula that will look at the dates in column A and count the number that have the same month and year as the date shown in column C.
 
Upvote 0
I understand exactly what you are trying to do. I am trying to get you to evaluate exactly what is in column C, if it is really a date or text.
And even if it is really a date, it may not be the date that you think it is!

It is vital to be fully aware of what we are working with so we can come up with a solution that will work for you.
So please tell us the answers to the questions I asked in post 3.
 
Upvote 0
Assuming they are all valid dates, try in D3
Excel Formula:
=COUNTIFS($A$2:$A$10000, ">=" & $C2, $A$2:$A$10000, "<=" & EOMONTH($C2,0))
 
Upvote 0
I originally missed the sentence above your sample data where you said:
(1/1/24 displayed as Jan-24, 2/1/24 displayed as Feb-24, etc)
and when I copied the data from your post to my spreadsheet, it made the dates 1/24/25, 2/24/25, 3/24/25, etc.
I wonder sure if it is a copy issue, or that is how your date really is entered. I am guessing a copy issue, based on what you said in your first post.

Sorry I missed that.
If that is indeed the case, Alex's formula should do what you want.
 
Upvote 0
T202503a.xlsm
ABEF
1Date ReceivedMonthCount
216-Jan-24Jan-243
317-Jan-24Feb-241
418-Jan-24Mar-243
525-Feb-24Apr-243
610-Mar-24Jun-244
721-Mar-24Jul-242
829-Mar-24Aug-244
93-Apr-24Sep-242
106-Apr-24Oct-242
1123-Apr-24Nov-245
125-Jun-24Dec-242
1310-Jun-24Jan-253
1413-Jun-24
1514-Jun-24
1610-Jul-24
1710-Jul-24
188-Aug-24
1912-Aug-24
2012-Aug-24
2123-Aug-24
2210-Sep-24
2315-Sep-24
248-Oct-24
2516-Oct-24
2610-Nov-24
2715-Nov-24
2816-Nov-24
2921-Nov-24
3028-Nov-24
3115-Dec-24
3222-Dec-24
337-Jan-25
3420-Jan-25
3526-Jan-25
2g
Cell Formulas
RangeFormula
E2:F13E2=LET(a,A1:A35-DAY(A1:A35)+1,GROUPBY(a,a,COUNT,1,0))
Dynamic array formulas.



With Excel 365 that has TrimRange, try the second example with you full range of data.
Custom format the Month Year to your preference.

T202503a.xlsm
ABHI
1Date ReceivedMonthCount
216-Jan-241-Jan-243
317-Jan-241-Feb-241
418-Jan-241-Mar-243
525-Feb-241-Apr-243
610-Mar-241-Jun-244
721-Mar-241-Jul-242
829-Mar-241-Aug-244
93-Apr-241-Sep-242
106-Apr-241-Oct-242
1123-Apr-241-Nov-245
125-Jun-241-Dec-242
1310-Jun-241-Jan-253
1413-Jun-24
1514-Jun-24
1610-Jul-24
1710-Jul-24
188-Aug-24
1912-Aug-24
2012-Aug-24
2123-Aug-24
2210-Sep-24
2315-Sep-24
248-Oct-24
2516-Oct-24
2610-Nov-24
2715-Nov-24
2816-Nov-24
2921-Nov-24
3028-Nov-24
3115-Dec-24
3222-Dec-24
337-Jan-25
3420-Jan-25
3526-Jan-25
36
37
38
39
2g
Cell Formulas
RangeFormula
H2:I13H2=LET(a,A.:.A-DAY(A.:.A)+1,GROUPBY(a,a,COUNT,1,0))
Dynamic array formulas.
 
Last edited:
Upvote 0
with custom format mmm-yy

T202503a.xlsm
HI
1MonthCount
2Jan-243
3Feb-241
4Mar-243
5Apr-243
6Jun-244
7Jul-242
8Aug-244
9Sep-242
10Oct-242
11Nov-245
12Dec-242
13Jan-253
14
2g
Cell Formulas
RangeFormula
H2:I13H2=LET(a,A.:.A-DAY(A.:.A)+1,GROUPBY(a,a,COUNT,1,0))
Dynamic array formulas.
 
Upvote 0
with power query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date Received", type date}}),
    #"Inserted Month Name" = Table.AddColumn(#"Changed Type", "Month Name", each Date.MonthName([Date Received]), type text),
    #"Inserted Year" = Table.AddColumn(#"Inserted Month Name", "Year", each Date.Year([Date Received]), Int64.Type),
    #"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Inserted Year", {{"Year", type text}}, "en-US"),{"Month Name", "Year"},Combiner.CombineTextByDelimiter(":", QuoteStyle.None),"Month:Year"),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Columns",{"Date Received"}),
    #"Grouped Rows" = Table.Group(#"Removed Columns", {"Month:Year"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"
Book5
ABCD
1Date ReceivedMonth:YearCount
21/16/2024January:20243
31/17/2024February:20241
41/18/2024March:20243
52/25/2024April:20243
63/10/2024June:20244
73/21/2024July:20242
83/29/2024August:20244
94/3/2024September:20242
104/6/2024October:20242
114/23/2024November:20245
126/5/2024December:20242
136/10/2024January:20253
146/13/2024
156/14/2024
167/10/2024
177/10/2024
188/8/2024
198/12/2024
208/12/2024
218/23/2024
229/10/2024
239/15/2024
2410/8/2024
2510/16/2024
2611/10/2024
2711/15/2024
2811/16/2024
2911/21/2024
3011/28/2024
3112/15/2024
3212/22/2024
331/7/2025
341/20/2025
351/26/2025
Sheet1
 
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