DSUM
Sums values in a database field for records that match criteria.
DSUM filters database rows using a criteria range, then adds the selected field values.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=DSUM(database, field, criteria)
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
database | any | Required | — |
field | any | Required | — |
criteria | any | Required | — |
Remarks
- An equality criterion for a date or number (
"10/26/1999","36459",36459) also matches text cells holding that date;<>and ordering criteria do not read date text. - Criteria rows are evaluated with OR semantics; populated criteria columns within one row are ANDed.
- Non-numeric values in the target field are ignored unless they coerce to numbers.
Error cases
fieldresolves by case-insensitive header text or 1-based column index; unknown headers and out-of-range indexes return#VALUE!.
Examples
Add the values in the Score column for the two East records.
Formula =DSUM(A1:B4,"Score",D1:D2)
| A | B | D | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "East" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result 18
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Use field number 2 to get the same sum for East.
Formula =DSUM(A1:B4,2,D1:D2)
| A | B | D | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "East" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result 18
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
With the West filter, only the score of 3 contributes to the sum.
Formula =IFERROR(DSUM(A1:B4,"Score",E1:E2),"Insufficient data")
| A | B | E | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "West" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result 3
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
The missing field header prevents calculating the sum for East.
Formula =DSUM(A1:B4,"Missing",D1:D2)
| A | B | D | |
|---|---|---|---|
| 1 | "Team" | "Score" | "Team" |
| 2 | "East" | 8 | "East" |
| 3 | "West" | 3 | |
| 4 | "East" | 10 |
Expected result #VALUE!
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Sum revenue for East or West regions
Formula =DSUM(A1:E7, "Revenue", G1:G3)
| A | B | C | D | E | G | |
|---|---|---|---|---|---|---|
| 1 | "Region" | "Salesperson" | "Product" | "Units" | "Revenue" | "Region" |
| 2 | "West" | "Diaz" | "Widget" | 24 | 126000 | "West" |
| 3 | "East" | "Patel" | "Gadget" | 31 | 142500 | "East" |
| 4 | "North" | "Kim" | "Widget" | 18 | 87000 | |
| 5 | "West" | "Ramos" | "Service" | 12 | 46000 | |
| 6 | "South" | "Lee" | "Gadget" | 27 | 119000 | |
| 7 | "East" | "Noor" | "Widget" | 22 | 101000 |
Expected result 415500
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Sum revenue by field index with numeric criteria
Formula =DSUM(A1:E7, 5, G1:G2)
| A | B | C | D | E | G | |
|---|---|---|---|---|---|---|
| 1 | "Region" | "Salesperson" | "Product" | "Units" | "Revenue" | "Units" |
| 2 | "West" | "Diaz" | "Widget" | 24 | 126000 | ">20" |
| 3 | "East" | "Patel" | "Gadget" | 31 | 142500 | |
| 4 | "North" | "Kim" | "Widget" | 18 | 87000 | |
| 5 | "West" | "Ramos" | "Service" | 12 | 46000 | |
| 6 | "South" | "Lee" | "Gadget" | 27 | 119000 | |
| 7 | "East" | "Noor" | "Widget" | 22 | 101000 |
Expected result 488500
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Related functions
FAQ
How are multiple criteria rows interpreted in DSUM?
Each criteria row is an OR branch, while multiple populated criteria columns in one row are combined with AND.