This article describes the formula syntax and use of the DSUM function in Microsoft Excel.
Description
In a list or database, DSUM provides the sum of the numbers in fields (columns) of records that match your specified conditions.
Syntax
DSUM(database, field, criteria)
The DSUM function syntax has the following arguments:
-
Database Required. This is the range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of a list contains labels for each column therein.
-
Field Required. This specifies which column is used in the function. Specify the column label enclosed between double quotation marks, such as "Age" or "Yield," for example. Alternatively, you can specify a number (without quotation marks) that represents the position of the column within the list: e.g., 1 for the first column, 2 for the second column, and so on.
-
Criteria Required. This is the range of cells that contains the conditions that you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.
Remarks
-
You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label for specifying the condition.
For example, if the range G1:G2 contains the column label Income in G1 and the amount $10,000 in G2, you could define the range as MatchIncome and use that name as the criteria argument in the database functions.
-
While the criteria range can be located anywhere on the worksheet, it is best to not place it below the list. This is risky. If you add more information to the list, the new information is added to the first row below the list. If the row below the list is not blank, Microsoft Excel will not add the new information.
-
Make sure that the criteria range does not overlap the list.
-
To perform an operation on an entire column in a database, enter a blank line below the column labels in the criteria range.
Example
Copy this entire example table (including the DSUM formula rows) and paste it in cell A1 of a new Excel worksheet. If the formula rows do not automatically show results, select them, press F2, and then press Enter. You may want to adjust column widths for easier viewing of all information.
Tree |
Height |
Age |
Yield |
Profit |
Height |
---|---|---|---|---|---|
="=Apple" |
>10 |
<16 |
|||
="=Pear" |
|||||
. |
|||||
Tree |
Height |
Age |
Yield |
Profit |
|
Apple |
18 |
20 |
14 |
$105 |
|
Pear |
12 |
12 |
10 |
$96 |
|
Cherry |
13 |
14 |
9 |
$105 |
|
Apple |
14 |
15 |
10 |
$75 |
|
Pear |
9 |
8 |
8 |
$77 |
|
Apple |
8 |
9 |
6 |
$45 |
|
Formula |
Description |
Result |
|||
=DSUM(A5:E11,"Profit",A1:A2) |
The total profit from apple trees (rows 6, 9, and 11). |
$225 |
|||
=DSUM(A5:E11,"Profit", A1:F3) |
The total profit from apple trees with a height between 10 and 16 feet, and all pear trees (rows 7, 9, and 10). |
$248 |