Adding data from specific years

Marvo

Board Regular
Joined
Nov 27, 2023
Messages
206
Office Version
  1. 2021
Platform
  1. Windows
Hi, I'm trying to total data from specific year. 2009, 2010 and 2011. If I enter the following
=SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2009")
it produces the correct result for 2009
If I then add to the formula
=SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2009")+SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2010")
it produces the correct result for 2009 & 2010
However if I add the third condition
=SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2009")+SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2010")+SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2011")
it no longer produces a result at all AND it also stops the second condition working too.
Any idea why?

I'm sure in all likelihood the formula could be simplified for all three years as it is repeating itself but I don't know how.

Many thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I suppose an easier way to ask this is, can/how do I construct these three formulas into one?
=SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2009")
=SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2010")
=SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2011")
 
Upvote 0
Untested here but try :

To combine these three formulas into one, you can use the SUM function to sum the results of the three SUMIFS formulas. The combined formula will look like this:

VBA Code:
=SUM(
    SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2009"),
    SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2010"),
    SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2011")
)


Alternatively, if the year values are contiguous and you want to avoid repeating the SUMIFS function for each year, you can adjust the criteria to match a range of years using the SUMPRODUCT function:

VBA Code:
=SUMPRODUCT(
    (ALL!$N:$N=$B17) * (ALL!$D:$D>="2009") * (ALL!$D:$D<="2011") * (ALL!$L:$L)
)
 
Upvote 0
Thank you. I placed this in the cell

=SUM(SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2009"),SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2010"),SUMIFS(ALL!$L:$L,ALL!$N:$N,$B17,ALL!$D:$D,"2011"))

But it produces no result? Not an error, just shows the formula as is?
 
Upvote 0
This is a bit weird. I put the original formula in in one go.

=SUMIFS(ALL!$L:$L,ALL!$N:$N,B17,ALL!$D:$D,"2009")+SUMIFS(ALL!$L:$L,ALL!$N:$N,B17,ALL!$D:$D,"2010")+SUMIFS(ALL!$L:$L,ALL!$N:$N,B17,ALL!$D:$D,"2011")

and it worked producing the correct result. But to then when copying the formula to another cell, not only doesn't it work but you also stop the original working. Same if you alter the formula in even the slightest way like adding a $.
 
Upvote 0
You could try this :

VBA Code:
=SUMPRODUCT((ALL!$L$2:$L$1000) *
   (ALL!$N$2:$N$1000 = B17) *
   ((ALL!$D$2:$D$1000 = "2009") + (ALL!$D$2:$D$1000 = "2010") + (ALL!$D$2:$D$1000 = "2011")))
 
Upvote 0
Apologies. I've had to give up, weird stuff going on. Its a new lap top and things aren't going to plan. I was deleting stuff from cells. The cells were showing as empty but when I looked at the bar above the stuff was still in there. I've never known anything like it. Sorry for wasting your valuable time.
 
Upvote 0
No problem. As far as the data not showing in the cells, what about the font color ?
 
Upvote 0
No, its something else. I put a formula in a cell, then it went awry, so I deleted the formula and the cells shows as empty, until you look in the bar above and its still there. Clear contents, still there, the only way to get rid of it was to cope over a blank cell. I've never known anything like it. I think that's why I couldn't get your formula to work, I think it may have been adding to whatever was already in there. Maybe I've got a dodgy copy of excel, yesterday it wouldn't sort percentages correctly (large to small). Annoying and frustrating.
 
Upvote 0
You could uninstall Excel, reboot your computer then reload Excel.

Or you could try repairing Excel first.
 
Upvote 0

Forum statistics

Threads
1,226,074
Messages
6,188,727
Members
453,494
Latest member
Alt F11

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