Skip to main content

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

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


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!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
hi what if the date is also added to it and then how we can calculate total for particular item, date wise. see below
Date item qty
3-Mar-21 blue 24
3-Mar-21 green 15
3-Mar-21 green 46
3-Mar-21 Blue 54
3-Mar-21 Red 6
4-Mar-21 Red 18
4-Mar-21 Blue 21
4-Mar-21 green 39
4-Mar-21 green 52
4-Mar-21 red 35
4-Mar-21 blue 19
5-Mar-21 green 54
5-Mar-21 green 26
5-Mar-21 Blue 29
5-Mar-21 Red 31
5-Mar-21 Red 74
5-Mar-21 Blue 20
5-Mar-21 green 85
5-Mar-21 green 56
This comment was minimized by the moderator on the site
Not exactly working for me. The A1 in the A2=A1 is does not stay constant once pasted and is off always by one row. If I lock the cell, in my case =IF(A2=$A$1,"",SUMIF(A:A,A2,H:H)), The formula works but populates in every column cell.
This comment was minimized by the moderator on the site
How use =IF(A2=A1,"",SUMIF(A:A,A2,B:B))
If in coloumn A data Blue is come after black
This comment was minimized by the moderator on the site
Please Reply
This comment was minimized by the moderator on the site
You can sort the data firstly to make sure that same data together.
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Skip the IF part and just use =SUMIF(A:A,A2,B:B)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations