What is the DSUM function?
=DSUM(database, field, criteria)DSUM picks only the records in a list (database) that meet a criteria table and adds the values of the field (column) you choose. Its conditions are written as a separate table on the sheet.
F1:G3 is the criteria table: F2 holds "Seoul", F3 holds "Busan" and G2 holds ">=40000". Drag the criteria range to F1:F2 (Seoul), F1:F3 (Seoul or Busan) or F1:G2 (Seoul with sales of 40000 or more).
DSUM shines in sales reports where you want to switch the totals just by editing the criteria cells. More rows in the criteria table mean OR, more columns on one row mean AND, so "Seoul or Busan" is a simple two-row table instead of two SUMIFS added together.
Arguments
- database
- The whole list. The first row must hold the headers.
- field
- The column to calculate: a column number (the first column is 1), a header name such as "Sales", or a cell holding the header (D1).
- criteria
- The criteria table. Its first row uses the same headers as the database, with the conditions below.
DSUM examples
Example 1. Basic use
=DSUM(A1:D9, 4, F1:F2)Adds Seoul sales 45000, 25600 and 96000: 166600.
Example 2. Changing the criteria
=DSUM(A1:D9, "Sales", F1:F3)Adds all sales for Seoul or Busan.
Example 3. Totals for each criteria range
=DSUM(A1:D9, "Sales", criteria)The same formula with only the criteria range changed.
Criteria range Records Result F1:F2 Seoul 166,600 F1:F3 Seoul or Busan 300,400 G1:G2 Sales of 40000 or more 266,100 F1:G2 Seoul and 40000 or more 141,000
Common mistakes
Leaving the header out of the criteria range
The first row of the criteria range must be a header. If you select F2:F3, "Seoul" is read as the header and you get the wrong result.
Mixing up AND and OR
Conditions on the same row must all be met (AND); conditions on different rows only need one to be met (OR).
Text criteria mean "begins with"
A criterion of "S" matches every branch that starts with S, such as Seoul. For an exact match, write ="=Seoul" in the criteria cell.
FAQ
- How is it different from SUMIFS?
- You can get the same results, but database functions keep the conditions in a table on the sheet, which makes OR conditions and changing conditions easy.
- Can I give the field as a name?
- Yes. Use a header name in double quotes, such as "Sales", or a cell that holds the header.
- What if a criteria row is blank?
- A blank row in the criteria range means "no condition", so every record is added.