How can I "group by" and sum a column in excel?

The feature you want to use is Pivot Tables. It's really easy to do exactly what you want with just a few clicks once you learn how to use that feature.


You can also do this with the Subtotal feature.

  1. Click the Data tab in Excel's ribbon toolbar
  2. Click the Sort button and sort by your category column
  3. Click the Subtotal button and fill in the dialog as appropriate, then click OK

For example...

At each change in: Category

Use function: Sum

Add subtotal to: Cost of Goods Sold


I am assuming that you are looking for the total COGS for an account like grocery for instance for week 1.

sumif is the easiest way to come up with that data. example taken from your picture:

=sumif(d2:d?,"grocery",j2:j?)

I have placed the question marks since I cannot see the whole sheet. You would select the entire column D where you have account data. D2 thru D?, Same with weekly usage column J2 thru J?.

The formula will look in the D column for the text grocery, if it is present it will add the cells in column J that correspond with D columns that have the word grocery in it. (or whatever text you put in the formula for it to look for)


To do this with a pivot table:

  1. Select all the data (including the column labels)
  2. Insert > PivotTable
  3. Drag a field into a dimension (row or column) of the pivot table to group by it
  4. Drag a field into the "values" area to calculate a metric about it; in this case, Sum.

enter image description here