COUNTIFS or SUMPRODUCT to include specific YEAR and specific MONTH

Kemidan2014

Board Regular
Joined
Apr 4, 2022
Messages
226
Office Version
  1. 365
Platform
  1. Windows
I was asked to create formulas to count how often we are replacing components of a tool.

i only have 2 columns Column A, a date is M/D/YYYY format and Column D the component number

here was my 2nd attempt at counting from the sheet after first failed.
=COUNTIFS('984 TCC1 SHEET'!D:D,"6509-1",'984 TCC1 SHEET'!A:A,"<="&DATE(W4,1,1),'984 TCC1 SHEET'!A:A,"<="&DATE(2021,X4,1))

Basically i want to CHOOSE what YEAR and what MONTH that the formula is counting by having dedicated cell one with year and one iwth a drop down list of the month (in the formualr W4 is year, X4 is month)
where am i going wrong in the syntax? my answer should be 4 because theres literally only 4 line items in the test list and all are november htis year and for that part number. but my result is 0
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try:

Dante Amor
ABCDWXY
1
2
3
401-nov6509-12021113
502-nov6509-2
603-nov6509-3
704-nov6509-4
805-nov6509-1
906-nov6509-2
1007-nov6509-3
1108-nov6509-4
1209-nov6509-1
1310-nov6509-2
14
984 TCC1 SHEET
Cell Formulas
RangeFormula
Y4Y4=COUNTIFS('984 TCC1 SHEET'!D:D,"6509-1", '984 TCC1 SHEET'!A:A,">="&DATE(W4,X4,1), '984 TCC1 SHEET'!A:A,"<="&EOMONTH(DATE(W4,X4,1),0))
 
Upvote 0
=COUNTIFS('984 TCC1 SHEET'!D:D,W6,'984 TCC1 SHEET'!A:A,">="&DATE($W$4,$X$4,1),'984 TCC1 SHEET'!A:A,"<="&DATE($W$4,$X$4,31))

i guess i had to sleep on it, i figured out how to get the results i needed
 
Upvote 0
Solution
DATE($W$4,$X$4,31))
Not all months end in 31 and that way you can get wrong results.

The correct thing would be like this:
Excel Formula:
=COUNTIFS('984 TCC1 SHEET'!D:D,W6,'984 TCC1 SHEET'!A:A,">="&DATE($W$4,$X$4,1),'984 TCC1 SHEET'!A:A,"<="&EOMONTH(DATE($W$4,$X$4,1),0))
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,315
Members
448,564
Latest member
ED38

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