Countifs matching year and month

pedexe90

Board Regular
Joined
Apr 18, 2018
Messages
59
Hi everyone,

I don't understand what's wrong with my formula, I am trying to count the number of received dates each month within that year with the following function:

COUNTIFS(MONTH('(DL here) queryTool'!$B$2:$B$48095),"="&'Graph 1 - Monthy Registered'!A5,YEAR('(DL here) queryTool'!$B$2:$B$48095),"="&'Graph 1 - Monthy Registered'!$A$4)

I have made a sample and uploaded it on OneDrive if you would like to have a look.

Thanks

https://1drv.ms/x/s!AgQdYsSdg735f8VN4vTtXjQMW5c
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I can't reach your file on Onedrive. However, I may told you where is wrong for your formula. The first parameter of COUNTIFS must be a range, for example A1:A100, it can't be an array calculated by other formula or function(except those returns a range reference). So you can't use month(range) as the first parameter of COUNTIFS.
 
Upvote 0
may be the following formula will returns what you want
Code:
=SUMPRODUCT((MONTH('(DL here) queryTool'!$B$2:$B$48095)='Graph 1 - Monthy Registered'!A5)*(YEAR('(DL here) queryTool'!$B$2:$B$48095)='Graph 1 - Monthy Registered'!$A$4))
 
Upvote 0
Simply, its' pattern is:

=sumproduct((list1=criteria1)*(list2=criteria2))
 
Upvote 0
Simply, its' pattern is:

=sumproduct((list1=criteria1)*(list2=criteria2))


Thanks for the quick reply.

The function =SUMPRODUCT((MONTH('(DL here) queryTool'!$B$2:$B$48095)='Graph 1 - Monthy Registered'!A5)*(YEAR('(DL here) queryTool'!$B$2:$B$48095)='Graph 1 - Monthy Registered'!$A$4))

Returns zero values. May ask another question, whats the difference between --() when defining criteria in a sumproduct function and using *?

https://1drv.ms/x/s!AgQdYsSdg735f8VN4vTtXjQMW5c
 
Upvote 0
The first question, please use Ctrl+shift+enter run the formula, not just hit Enter to finish.
The second question, --(),+0,-0,N() can change logical value TRUE and FALSE to 1 and 0, "*" works as well. For example, TRUE*TRUE=1, TRUE*FALSE=0.
 
Last edited:
Upvote 0
Sorry, I can't open the file. I can't ever open the link I created for my file on Onedrive, may be it because the server is in USA.

The form of formula =SUMPRODUCT((MONTH(A2:A6471)=C4)*(YEAR(A2:A6471)=C3)) is right. Can you send the attachment to me at shaowu459@163.com?
 
Upvote 0
You can use countifs for this type of count. You would just count what was greater then or equal to the 1st of the month in question and less than the 1st of the next month. As an example based on the file:

=COUNTIFS(A:A,">="&("1"&C4&$C$3),A:A,"<"&EOMONTH(("1"&C4&$C$3),0)+1)

The "1"&C4 bit may need to be C4&"1" based on the locale.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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