SUMPRODUCT help please

BamLindsay

New Member
Joined
Jan 16, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello,

Hoping someone can help me with a sumproduct formula that is not giving me the right answer please. I have a P&L with month in the column and GL code in the row and I am trying to create a formula that will add all the columns less than or equal to a given date input so that I can calculate the year to date number depending on month input.

1705400396571.png


The formula seems to work on most of the rows but not for all of them (see above). The formula I am using is =SUMPRODUCT(($AF$14:$MX$179)*($B$14:$B$179=$B45)*($AF$7:$MX$7<=$OD$5)). I can't figure out why for this row it does not seem to add up to the correct value. Any help is much appreciated.

Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Welcome to the forum.

Unfortunately, there is no way to tell from that picture. If it works for every other row, it's almost certainly a data issue, but we can't see the data and we don't know what your sum formula is looking at.
 
Upvote 0
one thing I can think of is you have another cell(s) in column B has the same lable, e.g. another 50301-... down the column.
one way to check it is temporary rename the lable to "x" for example to see if you get the sumproduct sum right
 
Upvote 0
Hi Rory, thanks for your reply. Apologies, is the below screenshot better which includes the rows? The data in the grey cells is just hardcoded numbers. I am using the sumproduct formula in my first post in column OC and my manual sum in OD is just =AF+BJ+CN+DR etc up to column LT for Dec-23. There are hidden columns between each month but they do not contain the month header in row 7 so should not be double summing anything. Thanks!

1705402963064.png
 
Upvote 0
Hi Alan, thanks for your suggestion. I did think of that as well but all the names in column B are unique. I changed the name to 'x' and it gave the same result.
 
Upvote 0
all the names in column B are unique.
Then why have this red section in the formula?
And why would the blue section need to cover all rows?
=SUMPRODUCT(($AF$14:$MX$179)*($B$14:$B$179=$B45)*($AF$7:$MX$7<=$OD$5))

Wouldn't this give the same result on row 45 with a lot less calculation?
=SUMPRODUCT((AF45:MX45)*($AF$7:$MX$7<=$OD$5))


There are hidden columns between each month but they do not contain the month header in row 7
.. but could those hidden row 7 values contain a numerical value, or even be blank? If so, those columns are likely included in the SUMPRODUCT result
Example

1705404231581.png


Now unhiding column AJ we see why the OC45 value is incorrect. I'm not saying this is your problem, just that it could be a possibility.

1705404351526.png
 
Upvote 0
forget this, my bad
 
Last edited:
Upvote 0
Seems like those date headings occur every 30 columns so what happens if you try this formula in row 45 (& copy up/down)
Excel Formula:
=SUMPRODUCT((AF45:MX45)*($AF$7:$MX$7<=$OD$5)*(MOD(COLUMN(AF45:MX45)-COLUMN(AF45),30)=0))
 
Upvote 0
Thank you, Peter! that formula has worked and I have learned something new about excel which always gets me excited. I think you were right, my formula was double counting items in the hidden columns and I was failing to understand that the formula will just read a date as a number and anything less than would also be picked up even if it wasn't a date format.

Many thanks to everyone for their input.
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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