Sum all values for all ocurrences when multiple matches

bais

New Member
Joined
Apr 15, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi

I've been struggling with summing up values in a dataset where there's multiple occurences of the category I need to sum for.
Ive made a small dataset illustrating the issue.

ABCDEFGHIJKLMNOQ
1JFMAMJJASONDAccumulated to date
2Apples
1​
5​
3​
6​
9​
2​
3​
1​
Apples
3Oranges
2​
3​
4​
2​
1​
3​
4​
5​
Oranges
4Bananas
3​
1​
5​
7​
2​
6​
8​
0​
Bananas
5Grapes
1​
3​
5​
4​
7​
2​
6​
0​
Grapes
6Lemons
3​
1​
5​
7​
2​
6​
8​
0​
Lemons
7Apples
0​
4​
9​
6​
9​
5​
3​
1​
8Grapes
1​
5​
3​
6​
9​
2​
3​
1​

So what I'm trying to achieve is having all values, for all month, for all categories summed and written in Q2. In the example Apple and Grape both occurs two times and that's the headache.
So I need the summed values to consider all values for all occurences of a category
NB: The categories can occur on any place in the set, so it's not given that it's A2 and A7 as it's the case for Apple in the example dataset

I had to sort it out for now by adding a SUM column after the dataset (ie. after M) And calculate the summed values using SUMIF in column Q
But I'm sure there's a more elegant way of achieving it, ie. without the SUM column.

So I turn to the experts on this forum, which I stumbled across trying to achieve the above :)
I found several examples which was sort of similar but not exactly the same, so I tried a little with Array functions, SUMPRODUCT and other "exotic" formulas (at least they were to me) :)

Thanks so much in advance for your time and assistance

/bais
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi & welcome to MrExcel.
How about
=SUMPRODUCT(($A$2:$A$8=O2)*($B$2:$M$8))
 
Upvote 0
Hi & welcome to MrExcel.
How about
=SUMPRODUCT(($A$2:$A$8=O2)*($B$2:$M$8))
Well hey presto!
I definitely came to the right place!
That was exactly what I couldn't get to work on my own

Thanks a whole bunch!
Have a nice day
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
If your Excel 365 has the FILTER function, then you could also use this.

20 04 16.xlsm
ABCDEFGHIJKLMNOP
1JFMAMJJASONDAccumulated to date
2Apples15369231Apples67
3Oranges23421345Oranges24
4Bananas31572680Bananas32
5Grapes13547260Grapes58
6Lemons31572680Lemons32
7Apples04969531
8Grapes15369231
SUM
Cell Formulas
RangeFormula
P2:P6P2=SUM(FILTER(B$2:M$8,A$2:A$8=O2))
 
Upvote 0
If your Excel 365 has the FILTER function, then you could also use this.

20 04 16.xlsm
ABCDEFGHIJKLMNOP
1JFMAMJJASONDAccumulated to date
2Apples15369231Apples67
3Oranges23421345Oranges24
4Bananas31572680Bananas32
5Grapes13547260Grapes58
6Lemons31572680Lemons32
7Apples04969531
8Grapes15369231
SUM
Cell Formulas
RangeFormula
P2:P6P2=SUM(FILTER(B$2:M$8,A$2:A$8=O2))

Yeah, thanks that worked too
 
Upvote 0
Yeah, thanks that worked too
(y)

BTW, if it is possible that a fruit in column O does not exist in column A, then my formula would actually need to be

=SUM(FILTER(B$2:M$8,A$2:A$8=O2,0))
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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