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?
doc sum by group 1

Sum values by group with using formula

Calculate or combine values by group with using Kutools for Excel

Sum values by group with using formula

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.
doc sum by group 2

Calculate or combine values by group with using Kutools for Excel

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.
doc sum by group 3

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.
doc sum by group 4

3. Click Ok, then the values will be calculated or combined as below screenshot shown:

 Sum by group  Combine by group
doc sum by group 5   doc sum by group 6

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Amol · 4 months ago
    How use =IF(A2=A1,"",SUMIF(A:A,A2,B:B))
    If in coloumn A data Blue is come after black
    • To post as a guest, your comment is unpublished.
      Amol · 4 months ago
      Please Reply
      • To post as a guest, your comment is unpublished.
        Sunny · 3 months ago
        You can sort the data firstly to make sure that same data together.
  • To post as a guest, your comment is unpublished.
    tp0908 · 1 years ago
    Sum 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
    • To post as a guest, your comment is unpublished.
      pelle · 1 years ago
      Skip the IF part and just use =SUMIF(A:A,A2,B:B)