Extending a formula to recognize an additional field regarding dates and months

searchingforhelp

Board Regular
Joined
Nov 11, 2020
Messages
67
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to manipulate the formula by counting how many "YES" are in a particular month.

Calendar Days.xlsx
ABCD
1DateCategoryMonthTotal by Month
25/10/2021YesJan-210
37/3/2021YesFeb-210
49/21/2021YesMar-210
512/12/2021NoApr-211
64/15/2021NoMay-214
75/20/2021YesJun-210
85/25/2021YesJul-212
912/1/2021NoAug-210
105/6/2021NoSep-211
117/15/2021NoOct-210
Sheet5
Cell Formulas
RangeFormula
D2:D11D2=COUNTIFS(A:A,">="&C2,A:A,"<="&EOMONTH(C2,0))
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Book1
ABCD
1DateCategoryMonthTotal by Month
25/10/2021YesJan-20210
37/3/2021YesFeb-20210
49/21/2021YesMar-20210
512/12/2021NoApr-20210
64/15/2021NoMay-20213
75/20/2021YesJun-20210
85/25/2021YesJul-20211
912/1/2021NoAug-20210
105/6/2021NoSep-20211
117/15/2021NoOct-20210
Sheet1
Cell Formulas
RangeFormula
D2:D11D2=SUMPRODUCT((MONTH($A$2:$A$11)=MONTH(C2))*($B$2:$B$11="Yes"))
 
Upvote 0
Book1
ABCD
1DateCategoryMonthTotal by Month
25/10/2021YesJan-20210
37/3/2021YesFeb-20210
49/21/2021YesMar-20210
512/12/2021NoApr-20210
64/15/2021NoMay-20213
75/20/2021YesJun-20210
85/25/2021YesJul-20211
912/1/2021NoAug-20210
105/6/2021NoSep-20211
117/15/2021NoOct-20210
Sheet1
Cell Formulas
RangeFormula
D2:D11D2=SUMPRODUCT((MONTH($A$2:$A$11)=MONTH(C2))*($B$2:$B$11="Yes"))

Hi Joe,

Thank you for your help. I tried to adjust the formula to capture the entire column as the data I am working with is not limited to 10 rows. Unfortunately, I cannot get it to work. See below

Calendar Days.xlsx
ABCD
1DateCategoryMonthTotal by Month
25/10/2021YesJan-21#VALUE!
37/3/2021YesFeb-21#VALUE!
49/21/2021YesMar-21#VALUE!
512/12/2021NoApr-21#VALUE!
64/15/2021NoMay-21#VALUE!
75/20/2021YesJun-21#VALUE!
85/25/2021YesJul-21#VALUE!
912/1/2021NoAug-21#VALUE!
105/6/2021NoSep-21#VALUE!
117/15/2021NoOct-21#VALUE!
Sheet5
Cell Formulas
RangeFormula
D2:D11D2=SUMPRODUCT((MONTH(A:A)=MONTH(C2))*(B:B="Yes"))
 
Upvote 0
Don't use full columns. Just use a range that easily exceeds the maximum you might ever use. For example, say the max is 5000 rows in col A. Then you could use this in cell C2:

=IF($A2="","",SUMPRODUCT((MONTH($A$2:$A$6000)=MONTH(C2))*($B$2:$B$6000="Yes")))
drag the formula down to A6000.

BTW: this will count all "Yes" entries in the particular month, regardless of year. If you may have multiple year values included in the dates in col A and you only wish to count those in say 2021 you need to add another condition, like this:
=IF($A2="","",SUMPRODUCT((MONTH($A$2:$A$6000)=MONTH(C2))*(YEAR($A$2:$A$6000)=YEAR(C2))*($B$2:$B$6000="Yes")))
 
Upvote 0
Don't use full columns. Just use a range that easily exceeds the maximum you might ever use. For example, say the max is 5000 rows in col A. Then you could use this in cell C2:

=IF($A2="","",SUMPRODUCT((MONTH($A$2:$A$6000)=MONTH(C2))*($B$2:$B$6000="Yes")))
drag the formula down to A6000.
Don't use full columns. Just use a range that easily exceeds the maximum you might ever use. For example, say the max is 5000 rows in col A. Then you could use this in cell C2:

=IF($A2="","",SUMPRODUCT((MONTH($A$2:$A$6000)=MONTH(C2))*($B$2:$B$6000="Yes")))
drag the formula down to A6000.

BTW: this will count all "Yes" entries in the particular month, regardless of year. If you may have multiple year values included in the dates in col A and you only wish to count those in say 2021 you need to add another condition, like this:
=IF($A2="","",SUMPRODUCT((MONTH($A$2:$A$6000)=MONTH(C2))*(YEAR($A$2:$A$6000)=YEAR(C2))*($B$2:$B$6000="Yes")))

BTW: this will count all "Yes" entries in the particular month, regardless of year. If you may have multiple year values included in the dates in col A and you only wish to count those in say 2021 you need to add another condition, like this:
=IF($A2="","",SUMPRODUCT((MONTH($A$2:$A$6000)=MONTH(C2))*(YEAR($A$2:$A$6000)=YEAR(C2))*($B$2:$B$6000="Yes")))

Thank you Joe for your time. Perhaps providing a little background may help. I have two tabs in a workbook. I periodically pull data from an application and dump the results in Excel format in the first tab. The old data is completely removed/deleted and the new data takes its place. In the second tab I have formulas that automatically calculate what I need from the first tab. The data size can very from the periodic data pull. I am having difficulty using this formula in retrieving what is needed from the first tab.

Here is an example:

=IF('First Tab'!$A2="","",SUMPRODUCT((MONTH('First Tab'!$A$2:$A$6000)=MONTH('First Tab'!(C2))*('First Tab'!$B$2:$B$6000="yes")))

Again, thank you for your time.
 
Upvote 0
Why no mention of this in your OP? And what exactly is the "difficulty" you are experiencing? Perhaps you can use XL2BB to show a portion of the layouts in both tabs. Is cell C2 in the first tab or is it the second tab?
Thank you Joe for your time. Perhaps providing a little background may help. I have two tabs in a workbook. I periodically pull data from an application and dump the results in Excel format in the first tab. The old data is completely removed/deleted and the new data takes its place. In the second tab I have formulas that automatically calculate what I need from the first tab. The data size can very from the periodic data pull. I am having difficulty using this formula in retrieving what is needed from the first tab.

Here is an example:

=IF('First Tab'!$A2="","",SUMPRODUCT((MONTH('First Tab'!$A$2:$A$6000)=MONTH('First Tab'!(C2))*('First Tab'!$B$2:$B$6000="yes")))

Again, thank you for your time.
 
Upvote 0
Why no mention of this in your OP? And what exactly is the "difficulty" you are experiencing? Perhaps you can use XL2BB to show a portion of the layouts in both tabs. Is cell C2 in the first tab or is it the second tab?

Thank you for your reply and I truly appreciate the time you are taking to help me. I thought if I can get help with the basics, I would be able to figure out the rest. A learning experience for me.

Sheet1 has the Date, Yes or No and the Months. Sheet 2 only has the Months and Results. The difficulty is when I attempt to have the formula read the information in sheet 1, the results are N/A

Calendar Days.xlsx
ABC
1Sheet 1
2DateYes or NoMonth
35/10/2021YesJan-21
47/3/2021YesFeb-21
59/21/2021YesMar-21
612/12/2021NoApr-21
74/15/2021NoMay-21
85/20/2021YesJun-21
95/25/2021YesJul-21
1012/1/2021NoAug-21
115/6/2021NoSep-21
127/15/2021NoOct-21
1312/15/2021YesNov-21
1411/27/2021NoDec-21
Sheet1


Calendar Days.xlsx
ABC
1Sheet 2
2MonthResult
3Jan-21#N/A
4Feb-21#N/A
5Mar-21#N/A
6Apr-21#N/A
7May-21#N/A
8Jun-21#N/A
9Jul-21#N/A
10Aug-21#N/A
11Sep-21#N/A
12Oct-21#N/A
13Nov-21#N/A
14Dec-21#N/A
Sheet2
Cell Formulas
RangeFormula
C3:C14C3=IF(Sheet1!$A3="","",SUMPRODUCT((MONTH(Sheet1!$A$3:$A$6000)=MONTH(Sheet1!C3))*(YEAR(Sheet1!$A$3:$A$6000)=YEAR(Sheet1!C3))*(Sheet1!$B$2:$B$6000="yes")))
 
Upvote 0
Thank you for your reply and I truly appreciate the time you are taking to help me. I thought if I can get help with the basics, I would be able to figure out the rest. A learning experience for me.

Sheet1 has the Date, Yes or No and the Months. Sheet 2 only has the Months and Results. The difficulty is when I attempt to have the formula read the information in sheet 1, the results are N/A. And does the formula compensate for black cells?

Calendar Days.xlsx
ABC
1Sheet 1
2DateYes or NoMonth
35/10/2021YesJan-21
47/3/2021YesFeb-21
59/21/2021YesMar-21
612/12/2021NoApr-21
74/15/2021NoMay-21
85/20/2021YesJun-21
95/25/2021YesJul-21
1012/1/2021NoAug-21
115/6/2021NoSep-21
127/15/2021NoOct-21
1312/15/2021YesNov-21
1411/27/2021NoDec-21
Sheet1


Calendar Days.xlsx
ABC
1Sheet 2
2MonthResult
3Jan-21#N/A
4Feb-21#N/A
5Mar-21#N/A
6Apr-21#N/A
7May-21#N/A
8Jun-21#N/A
9Jul-21#N/A
10Aug-21#N/A
11Sep-21#N/A
12Oct-21#N/A
13Nov-21#N/A
14Dec-21#N/A
Sheet2
Cell Formulas
RangeFormula
C3:C14C3=IF(Sheet1!$A3="","",SUMPRODUCT((MONTH(Sheet1!$A$3:$A$6000)=MONTH(Sheet1!C3))*(YEAR(Sheet1!$A$3:$A$6000)=YEAR(Sheet1!C3))*(Sheet1!$B$2:$B$6000="yes")))

Thank you for your reply and I truly appreciate the time you are taking to help me. I thought if I can get help with the basics, I would be able to figure out the rest. A learning experience for me.

Sheet1 has the Date, Yes or No and the Months. Sheet 2 only has the Months and Results. The difficulty is when I attempt to have the formula read the information in sheet 1, the results are N/A

Calendar Days.xlsx
ABC
1Sheet 1
2DateYes or NoMonth
35/10/2021YesJan-21
47/3/2021YesFeb-21
59/21/2021YesMar-21
612/12/2021NoApr-21
74/15/2021NoMay-21
85/20/2021YesJun-21
95/25/2021YesJul-21
1012/1/2021NoAug-21
115/6/2021NoSep-21
127/15/2021NoOct-21
1312/15/2021YesNov-21
1411/27/2021NoDec-21
Sheet1


Calendar Days.xlsx
ABC
1Sheet 2
2MonthResult
3Jan-21#N/A
4Feb-21#N/A
5Mar-21#N/A
6Apr-21#N/A
7May-21#N/A
8Jun-21#N/A
9Jul-21#N/A
10Aug-21#N/A
11Sep-21#N/A
12Oct-21#N/A
13Nov-21#N/A
14Dec-21#N/A
Sheet2
Cell Formulas
RangeFormula
C3:C14C3=IF(Sheet1!$A3="","",SUMPRODUCT((MONTH(Sheet1!$A$3:$A$6000)=MONTH(Sheet1!C3))*(YEAR(Sheet1!$A$3:$A$6000)=YEAR(Sheet1!C3))*(Sheet1!$B$2:$B$6000="yes")))
And one more thing I noticed is when the fields are blank in column A or B the results in column D is empty. can it result in a zero instead?

Calendar Days.xlsx
ABCD
1Sheet 1
2DateYes or NoMonth
35/10/2021YesJan-210
47/3/2021YesFeb-210
5YesMar-21 
612/12/2021NoApr-210
74/15/2021May-212
85/20/2021Jun-210
95/25/2021YesJul-211
10NoAug-21 
115/6/2021Sep-210
127/15/2021NoOct-210
1312/15/2021YesNov-210
1411/27/2021NoDec-211
Sheet1
Cell Formulas
RangeFormula
D3:D14D3=IF($A3="","",SUMPRODUCT((MONTH($A$3:$A$6000)=MONTH(C3))*(YEAR($A$3:$A$6000)=YEAR(C3))*($B$3:$B$6000="Yes")))
 
Upvote 0
And one more thing I noticed is when the fields are blank in column A or B the results in column D is empty. can it result in a zero instead?

Calendar Days.xlsx
ABCD
1Sheet 1
2DateYes or NoMonth
35/10/2021YesJan-210
47/3/2021YesFeb-210
5YesMar-21 
612/12/2021NoApr-210
74/15/2021May-212
85/20/2021Jun-210
95/25/2021YesJul-211
10NoAug-21 
115/6/2021Sep-210
127/15/2021NoOct-210
1312/15/2021YesNov-210
1411/27/2021NoDec-211
Sheet1
Cell Formulas
RangeFormula
D3:D14D3=IF($A3="","",SUMPRODUCT((MONTH($A$3:$A$6000)=MONTH(C3))*(YEAR($A$3:$A$6000)=YEAR(C3))*($B$3:$B$6000="Yes")))
My apologies, I was not clear. For some reason when one of the cells are blank the formula does not calculate. In my data set, the first 103 rows are blank. The formula did not calculate when row 104 had the date and Yes. Sorry for many emails.
 
Upvote 0
First, I would leave the result cell empty (blank) if one of the cells in Sheet1 col A is blank. Otherwise, you end up with 0 all the way from your last data row to row 6000. Below is what I think you want to achieve. Note that the result cells are in Sheet2 NOT Sheet1. Note also that you need to adjust addresses in the formula to be consistent with your data layouts in the two sheets.
Book1
ABC
1Sheet 1
2DateYes or NoMonth
35/10/2021YesJanuary-21
47/3/2021YesFebruary-21
59/21/2021YesMarch-21
612/12/2021NoApril-21
74/15/2021NoMay-21
85/20/2021YesJune-21
95/25/2021YesJuly-21
1012/1/2021NoAugust-21
115/6/2021NoSeptember-21
127/15/2021NoOctober-21
1312/15/2021YesNovember-21
1411/27/2021NoDecember-21
Sheet1

Book1
ABC
1Sheet 2
2MonthResult
3January-210
4February-210
5March-210
6April-210
7May-213
8June-210
9July-211
10August-210
11September-211
12October-210
13November-210
14December-211
Sheet2
Cell Formulas
RangeFormula
C3:C14C3=IF(Sheet1!$A3="","",SUMPRODUCT((MONTH(Sheet1!$A$3:$A$6000)=MONTH(B3))*(YEAR(Sheet1!$A$3:$A$6000)=YEAR(B3))*(Sheet1!$B$3:$B$6000="yes")))
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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