SUMPRODUCT and MONTH/YEAR help

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
625
Office Version
  1. 2019
Platform
  1. Windows
=SUMPRODUCT(--('Rec. Shared'!$M$12:$M$1465=$I$1),--(MONTH('Rec. Shared'!$Y$12:$Y$1465)=MONTH(A17)),'Rec. Shared'!$U$12:$U$1465)

Need help to make the formula above more accurate. This formula reads the text in $I$1 to find MATCHES in $M$12:$M$1465. It also reads the month in A17 (Sep-11, in this case) and finds MATCHES in $Y$12:$Y$1465. It then totals values in $U$12:$U$1465 where both these conditions are met.

This formula is only totalling values from Sep-10 and completely disregarding Sep-11. I assume it also needs to search for the YEAR somehow. Can anyone help?

Dan
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
This is unexpected because I'd expect totals from all years to be included since there's no year ref at all in the formula!
Just to be sure, you refer to dates as Sep-!0, Sep-11, this means Sep-2011 ans Sep-2010, yes?

If you want to restrict to just one year then you need to add another bit within the SumProduct parentheses like:
--(YEAR('Rec. Shared'!$Y$12:$Y$1465)=YEAR(A17))

Otherwise, if you could post a version of your sheet on the interweb somewhere (eg.box.net)…
 
Upvote 0
=SUMPRODUCT(--('Rec. Shared'!$M$12:$M$1465=$I$1),--(MONTH('Rec. Shared'!$Y$12:$Y$1465)=MONTH(A17)),'Rec. Shared'!$U$12:$U$1465)

Need help to make the formula above more accurate. This formula reads the text in $I$1 to find MATCHES in $M$12:$M$1465. It also reads the month in A17 (Sep-11, in this case) and finds MATCHES in $Y$12:$Y$1465. It then totals values in $U$12:$U$1465 where both these conditions are met.

This formula is only totalling values from Sep-10 and completely disregarding Sep-11. I assume it also needs to search for the YEAR somehow. Can anyone help?

Dan
If A17 houses a true first day date of the month/year of interest like 1-Sep-2011, possibly formatted to display Sep-11, you can also invoke:

=SUMPRODUCT(
--('Rec. Shared'!$M$12:$M$1465=$I$1),
--('Rec. Shared'!$Y$12:$Y$1465-DAY('Rec. Shared'!$Y$12:$Y$1465)+1=A17),
'Rec. Shared'!$U$12:$U$1465)
 
Upvote 0
I've been successful wrapping things with the TEXT() function:

--(TEXT(MONTH('Rec. Shared'!$Y$12:$Y$1465,"mmm")=TEXT(A17,"mmm"))
 
Upvote 0
I've been successful wrapping things with the TEXT() function:

--(TEXT(MONTH('Rec. Shared'!$Y$12:$Y$1465,"mmm")=TEXT(A17,"mmm"))

The OP wants to cover both month and year. If you want to make use of TEXT, something like the following would be needed:

--(TEXT('Rec. Shared'!$Y$12:$Y$1465,"mmmyy")=TEXT(A17,"mmmyy"))
 
Upvote 0
Yes, Sep-11 (in 'mmm-yy' format) means Sep-2011. I am surprised that it only totalled values from Sep-10 and not Sep-11 also.

My months for the A Column (A17) are in 'mmm-yy' format displaying Sep-11, but showing 01/09/2011 in the formula bar as you thought, Aladin, so I've used your formula which does exactly what I'm after.

Thanks P45cal, Jim and Aladin for your help, it's been puzzling me for a while now, but problem solved. Thanks again.

Dan
 
Upvote 0
The OP wants to cover both month and year. If you want to make use of TEXT, something like the following would be needed:

--(TEXT('Rec. Shared'!$Y$12:$Y$1465,"mmmyy")=TEXT(A17,"mmmyy"))

Aladin, thanks My post should not have include the Month() portion, thus it should have been:

--(TEXT('Rec. Shared'!$Y$12:$Y$1465,"mmm")=TEXT(A17,"mmm"))

Thinking the Corrected formula would produce ALL Septs (regardless of year),
it would do so.. Correct? Jim:confused:
 
Upvote 0
Aladin, thanks My post should not have include the Month() portion, thus it should have been:

--(TEXT('Rec. Shared'!$Y$12:$Y$1465,"mmm")=TEXT(A17,"mmm"))

Thinking the Corrected formula would produce ALL Septs (regardless of year),
it would do so.. Correct? Jim:confused:

Yes, that's correct. Hence the need for "mmmyy" or "mmm-yy" or the like.
 
Upvote 0
Yes, Sep-11 (in 'mmm-yy' format) means Sep-2011. I am surprised that it only totalled values from Sep-10 and not Sep-11 also.

My months for the A Column (A17) are in 'mmm-yy' format displaying Sep-11, but showing 01/09/2011 in the formula bar as you thought, Aladin, so I've used your formula which does exactly what I'm after.

Thanks P45cal, Jim and Aladin for your help, it's been puzzling me for a while now, but problem solved. Thanks again.

Dan

You are welcome. Thanks for providing us feedback.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

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