How to sum values by group in Excel?
Here are two columns, one is the product name, and the other is Sales. Now I want to sum the sales by the same product as below screenshot shown. How can I solve it in Excel?
You can sum values by group with one formula easily in Excel.
Select next cell to the data range, type this =IF(A2=A1,"",SUMIF(A:A,A2,B:B)), (A2 is the relative cell you want to sum based on, A1 is the column header, A:A is the column you want to sum based on, the B:B is the column you want to sum the values.) Press Enter key, drag fill handle down to the cells to fill the formula.
If you want to do other calculations by groups, such count, find max or min value, or combine values based on group, you can try Kutools for Excel’s Advanced Combine Rows utility.
|Kutools for Excel, with more than 300 handy functions, makes your jobs more easier.|
After free installing Kutools for Excel, please do as below:
1. Select the data range then click Kutools > Merge & Split > Advanced Combine Rows.
2. In the Advanced Combine Rows dialog, please do as these:
1) Specify a column as the key column which is used to calculate or combine values based on;
2) Choose an option in one operation as you need.
3. Click Ok, then the values will be calculated or combined as below screenshot shown:
|Sum by group||Combine by group|
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 7 months agoSum Values By Group. Nice to have a good reference for users not familiar with excel formula scripting. I have used the same script but I cannot find a way to sort the result based on the summed values, in your example, I like to get summed valued from highest to lowest (105, 96, 83). I was able to do it by creating another column (say column D) to copy the summed amount corresponding to product (say, Blue will have 96 for D2, D3, D4 / 83 for D5, D6 and so on) then sort column D. But I think that is a crude way of doing it. Is there a built-in function in Excel or Kutools to have the sum and sort (based on summed values). Thanks