Practice free

DSUM function

DSUM adds up one column of a list for the rows that meet your criteria. It is an older cousin of SUMIFS that takes its criteria from a block of cells.

Example

Read it as a sentence: in the table Q1:S6, add up the Qty values of the rows where the Item matches the criteria in U1:U2 (Apple), which gives 40.

Practice this in the app

Syntax

DSUM(database, field, criteria)

database (required)
Range (with header row) that holds the list.
field (required)
Column to use, given as its header text in quotes or as a column number.
criteria (required)
Range with matching headers on top and conditions underneath.

Returns: The sum of matching values.

What Excel actually returns

Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.

FormulaExcel showsCase
=DSUM(Data!Q1:S6,"Qty",Data!U1:U2) 40 Criteria Item=Apple (2 rows)
=DSUM(Data!Q1:S6,"Qty",Data!V1:V2) 20 Criteria Item=Pear (1 row)
=DSUM(Data!Q1:S6,"Qty",Data!W1:W2) 0 No matching rows
=DSUM(Data!Q1:S6,"Qty",Data!X1:Y2) 10 AND criteria (same row)
=DSUM(Data!Q1:S6,"Qty",Data!Z1:Z3) 60 OR criteria (two rows)
=DSUM(Data!Q1:S6,"Qty",Data!AA1:AA2) 90 Numeric criteria >15
=DSUM(Data!Q1:S6,0,Data!U1:U2) #VALUE! Field number 0
=DSUM(Data!Q1:S6,4,Data!U1:U2) #VALUE! Field number beyond width

The Data sheet these formulas read

A cell that starts with = holds that formula.

Watch out for

  • Criteria headers must match the database headers exactly.
  • Excel refuses the formula outright if you type an array constant such as {1,2,3} where a range is expected; point it at cells instead (measured in Excel 16.0.20527).

Where it works

Excel
DSUM is in every version of Excel from 2007 on.
Google Sheets
Same name, same behaviour for everyday use. Sheets has it, but takes cell ranges; array-constant databases are Excel-only.

Part of Database functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .