Business tasks · Excel formula

Sum values by category

Use SUMIF to add values that share a category.

Illustrated spreadsheet concept

Use this formula

=SUMIF(A2:A6,"Travel",B2:B6)

The example below uses the column letters and row numbers in the formula. Enter it in a blank cell after the sample data.

See the cells and result

Visual example for Sum values by category with sample rows and expected result

Example data

RowCategoryAmount
2Travel120
3Software49
4Travel85
5Meals32
6Travel40

Expected result: 245.

Why it works

SUMIF checks each cell in A2:A6 for Travel and adds the matching amounts from B2:B6.

Check this: Text criteria go in quotation marks. The criteria range and sum range should cover the same number of rows.

Excel versions and testing

The example uses standard worksheet formulas. Open the workbook in a current desktop Excel version; other editions may display or calculate differently.

This original example has been checked against the browser formula engine and the downloadable workbook structure. The workbook has not been verified in every Excel edition. Microsoft function reference.

Common mistake and fix

If the total or count is wrong, compare the criterion text with the source cells and check that selected ranges cover the same rows.

Try it yourself

Change a number or label in the data and predict the new result. Use the practice lab to test a supported formula, or download the data to work in Excel.

Try this example onlineDownload Excel workbookDownload CSV