ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. How to Sum by Category in Excel

How to Sum by Category in Excel

By ExcelReady Team·Updated November 1, 2026·6 min read

The short answer

To sum by category in Excel, list each category once, then use SUMIF next to it: =SUMIF($A$2:$A$8,D2,$B$2:$B$8) adds the amounts in column B for the category named in D2. Fill it down for a full summary. In Excel 2021 or Microsoft 365, =UNIQUE(A2:A8) builds the category list for you, and a PivotTable does the same job without formulas.

Key takeaways

  • A category summary has two parts: a list of each category once, and a SUMIF next to each one.
  • Lock the ranges with $ signs and leave the category cell unlocked so the formula fills down.
  • In Excel 2021 or Microsoft 365, =SORT(UNIQUE(A2:A8)) builds and sorts the list automatically.
  • Check that the category totals add up to the grand total; a gap means a spelling or spacing difference.
  • Use SUMIFS when you need a second condition, such as category and month.
On this page+
  1. The sample data
  2. Step 1: List each category once
  3. Step 2: Total each category with SUMIF
  4. Step 3: Check the totals add up
  5. Build the category list automatically with UNIQUE
  6. Percent of total and the biggest category
  7. Sum by category with a second condition
  8. Sum by category with a PivotTable
  9. Practise it

To sum by category in Excel, you need two things: a list of each category once, and a SUMIF next to each name that adds up its amounts. That gives you a clean summary, such as total spend on Travel, Meals and Office, that updates whenever the data changes. This guide builds one step by step, then shows the automatic UNIQUE version, percent of total, a second condition and the PivotTable alternative.

The sample data#

Every example uses this expense list in A1:B8:

AB
1CategoryAmount
2Travel120
3Meals45
4Office80
5Travel300
6Meals60
7Software99
8Office35

The categories repeat in no particular order, which is how real data usually looks. The finished summary should show Travel 420, Meals 105, Office 115 and Software 99, for a grand total of 739.

Step 1: List each category once#

Type each category once in a new column, starting in D2: Travel, Meals, Office, Software. Add a header such as "Category" in D1. With a short list, typing is fine.

For a longer list, copy column A to column D, select it, and use Data > Remove Duplicates. Excel deletes the repeats and leaves one of each. The catch is that this list doesn't update: if a new category appears in the data later, you have to add it yourself.

Step 2: Total each category with SUMIF#

SUMIF adds the numbers in one range when the matching cells in another range meet a condition. Here the condition is "the category equals the name in column D". In E2, type:

Excel formula
=SUMIF($A$2:$A$8,D2,$B$2:$B$8)
PartWhat it does
$A$2:$A$8The category column to check
D2The category to match (Travel)
$B$2:$B$8The amounts to add

Press Enter: E2 shows 420 (120 + 300). Then fill down to E5 (Windows: Ctrl+D; Mac: ⌘D). The $ signs lock the two ranges so they don't slide down, while D2 has no $ and changes to D3, D4 and D5:

DE
1CategoryTotal
2Travel420
3Meals105
4Office115
5Software99

SUMIF ignores capitals, so "travel" in column D still matches "Travel". For a full walk-through of SUMIF, read how to use SUMIF, or see the SUMIF function guide.

Step 3: Check the totals add up#

Add the summary and compare it with the original column:

Excel formula
=SUM(E2:E5)

It should equal =SUM(B2:B8), which is 739. If the summary is smaller, some rows didn't match any category in your list. The usual causes are a missing category, a typo such as "Meal" instead of "Meals", or an extra space, like "Travel " with a trailing space. SUMIF needs an exact match, so those rows are left out without any warning. Clean the column with TRIM, fix the typos, and the totals will agree.

Build the category list automatically with UNIQUE#

In Excel 2021 or Microsoft 365, the UNIQUE function builds the list for you and updates it when the data changes. In D2, type:

Excel formula
=UNIQUE(A2:A8)

The result spills into the cells below: Travel, Meals, Office, Software, in the order they first appear. To sort them alphabetically, wrap it in SORT: =SORT(UNIQUE(A2:A8)).

Then point SUMIF at the whole spilled list with the # sign, which means "the full spill range starting at D2":

Excel formula
=SUMIF(A2:A8,D2#,B2:B8)

Type this once in E2 and it spills a total next to every category. Add a new category to the data and both columns grow on their own. If you see #SPILL!, something is blocking the cells below; clear them. The UNIQUE function guide has more examples, and older versions of Excel need the manual list from Step 1.

Percent of total and the biggest category#

Once you have the totals, a share of the total is one division away. In F2, type this and fill down, then format the column as a percentage:

Excel formula
=E2/SUM($E$2:$E$5)

Travel is 420 / 739, about 57% of all spending. To find the biggest category by formula, combine INDEX and MATCH with MAX: =INDEX(D2:D5,MATCH(MAX(E2:E5),E2:E5,0)) returns Travel.

Sum by category with a second condition#

When you need totals by category and something else, such as a month or a region, switch to SUMIFS. Say column C holds the expense date. Travel spending in January 2024 is:

Excel formula
=SUMIFS(B2:B8,A2:A8,"Travel",C2:C8,">="&DATE(2024,1,1),C2:C8,"<="&DATE(2024,1,31))

SUMIFS puts the sum range first, then a range and criteria for each condition. A grid with categories down the side and months across the top is a common report built this way; see how to sum by month and how to sum by date range. If your categories are buried inside longer descriptions, use wildcards as shown in SUMIF contains text.

Sum by category with a PivotTable#

A PivotTable gives the same totals without any formulas. Click anywhere in the data, go to Insert > PivotTable, and choose a new sheet. Drag Category to Rows and Amount to Values. Excel lists each category once and shows its sum, with a grand total at the bottom.

PivotTables are fast and easy to rearrange, but they don't update until you refresh them (right-click > Refresh). SUMIF is better for a report with a fixed layout that must always be current, while a PivotTable is better for exploring. Many job tests ask for both, so it is worth knowing each.

Practise it#

A category summary is one of the most common tasks in any Excel job. Practise SUMIF in a live spreadsheet: you type the formula and it checks it instantly. Then build a full summary table in the pivot-style summary lesson. When you're ready, try the data analyst Excel test.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

D2 holds the category Travel. In E2, use SUMIF to total the Amount (B2:B8) for the category in D2.

fx
ABCDEF
1
Category
Amount
Category
Total
2
Travel
120
Travel
3
Meals
45
4
Office
80
5
Travel
300
6
Meals
60
7
Software
99
8
Office
35
9
10
11

Tip: Check the categories in A2:A8, match the name in D2, and add the amounts in B2:B8.

Practise this in a lesson

LessonSUMIFAdd up only the numbers that meet a condition, with and without a separate sum range.LessonPivot-style summary with formulasBuild a summary table like a pivot table with formulas: a sorted UNIQUE list of categories, then SUMIFS and COUNTIFS filled down beside it.Function guideSUMIFAdd up values that meet one condition with SUMIF. Totals by category, person or amount, the argument-order trap, and a live exercise.Function guideUNIQUEList distinct values with Excel's UNIQUE, count them with COUNTA, or find items that appear only once. Examples plus a live exercise.

Frequently asked questions

How do I sum values by category in Excel?

+

List each category once in a column, then next to the first one type =SUMIF($A$2:$A$8,D2,$B$2:$B$8) and fill down. Each row shows the total for its category.

How do I get a list of unique categories in Excel?

+

In Excel 2021 or Microsoft 365, use =UNIQUE(A2:A8), or =SORT(UNIQUE(A2:A8)) for an alphabetical list. In older versions, copy the column and use Data > Remove Duplicates.

How do I sum by category and month?

+

Use SUMIFS with one condition for the category and two for the dates: =SUMIFS(B2:B8,A2:A8,"Travel",C2:C8,">="&DATE(2024,1,1),C2:C8,"<="&DATE(2024,1,31)).

Should I use SUMIF or a PivotTable to sum by category?

+

Use SUMIF when you want totals in a fixed layout that update on their own. Use a PivotTable for a quick summary you can rearrange, but remember to refresh it when the data changes.

Why does one category total look too low?

+

Some rows probably have a slightly different spelling, such as Travel with a trailing space. SUMIF needs an exact match apart from capitals, so clean the column with TRIM or fix the typos.

Sources

  • SUMIF function - Microsoft Support
  • UNIQUE function - Microsoft Support
  • Create a PivotTable to analyze worksheet data - Microsoft Support

Written and checked by the ExcelReady Team. First published November 1, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. The sample data
  2. Step 1: List each category once
  3. Step 2: Total each category with SUMIF
  4. Step 3: Check the totals add up
  5. Build the category list automatically with UNIQUE
  6. Percent of total and the biggest category
  7. Sum by category with a second condition
  8. Sum by category with a PivotTable
  9. Practise it

Keep reading

Conditional math· 7 min read

Sum by Date Range or Month in Excel With SUMIFS

To sum between two dates, give SUMIFS the same date column twice: once with ">="&start and once with "<"&end. For January 2025, write =SUMIFS(D2:D9,A2:A9,">="&DATE(2025,1,1),A2:A9,"<"&DATE(2025,2,1)). Keep the operator in quotes and join the date with &. Using "before the 1st of next month" works for every month.

Conditional math· 6 min read

How to Sum by Month in Excel With SUMIFS

To sum by month in Excel, put the first day of the month in a cell, such as D2, and use SUMIFS with two date conditions: =SUMIFS(B2:B8,A2:A8,">="&D2,A2:A8,"<="&EOMONTH(D2,0)). EOMONTH returns the last day of that month, so the formula adds every amount dated from the 1st to the month end. Fill it down for a monthly summary.

Conditional math· 7 min read

How to Use SUMIF in Excel

SUMIF adds up the numbers in the rows that meet one condition. Write =SUMIF(range, criteria, sum_range): the cells to check, what they must match, then the numbers to add. For example, =SUMIF(C2:C9,"Travel",D2:D9) totals all Travel claims. Leave out sum_range when the condition is about the numbers themselves.

More on conditional math

  • SUMIF Contains Text: Sum by Partial Match
  • SUMIF Greater Than or Less Than a Number
  • SUMIF Not Equal To: Exclude a Value From a Total
  • SUMIFS With OR Logic in Excel
  • Excel Wildcards: *, ? and ~ in COUNTIF and SUMIF
  • AVERAGEIF and AVERAGEIFS in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free