DSUM function
The DSUM function in Excel is used to sum the values in a specific field (column) of a database that meet certain criteria. It is part of Excel’s database functions and allows you to sum values based on multiple conditions defined in a criteria range.
Syntax
DSUM(database, field, criteria)
Parameters
database: The range of cells that contains the database, including column headers. The database should have column headers in the first row, and the data should be below those headers.field: The column in the database for which you want to sum the values. You can specify the field by:- Column name (in quotes), e.g.,
"Sales". - Column number, e.g.,
3for the third column in the database.
- Column name (in quotes), e.g.,
criteria: The range of cells that contains the condition(s) to filter the database. The criteria range should include at least one column header and the condition(s) below it.
How It Works
- DSUM sums the values in the specified field (column) for the records that meet the conditions defined in the criteria range.
- The criteria can be simple (e.g., summing all sales above a certain amount) or complex (e.g., summing sales for a specific product in a particular region).
- If no records meet the criteria, DSUM will return
0. - If the field is specified by column name, the function will sum values in the corresponding column. If the field is specified by column number, it will sum values in that specific column.
Example of Usage
Let’s say you have a database of product sales:
| Product | Region | Sales | Date |
|---|---|---|---|
| Laptop | East | 1000 | 2024-01-01 |
| Tablet | East | 2000 | 2024-01-02 |
| Phone | West | 1500 | 2024-01-03 |
| Laptop | West | 2500 | 2024-01-04 |
| Tablet | East | 1800 | 2024-01-05 |
You want to sum the Sales for products in the “East” region.
- Database range: A1:D6 (including headers).
- Field:
"Sales"(or3for the third column). - Criteria range: To filter by “East” in the “Region” column, set up the criteria range in cells F1:F2 like this:
| Region |
|---|
| East |
- Formula:
=DSUM(A1:D6, "Sales", F1:F2)
Or
=DSUM(A1:D6, 3, F1:F2)
Result: The formula will sum the Sales values for products in the “East” region, which would be 1000 + 2000 + 1800 = 5800.
Key Points
- Sum with Criteria: DSUM sums values in the specified field based on the conditions defined in the criteria range.
- Criteria: The criteria range can define one or more conditions to filter the data, such as summing sales greater than a certain amount or summing sales for a specific product or region.
- Field Reference: The field can be specified by either the column name (in quotes) or the column number.
- Error Handling:
0: If no records meet the criteria.- Blank Criteria: If the criteria range is blank, all records in the database are summed.
Common Use Cases
- Summing Values for a Specific Group: DSUM is useful when you want to sum values for a specific group, such as total sales for products in a specific region or total expenses for a specific department.
- Summing with Multiple Conditions: You can use multiple conditions in the criteria range to filter the data further, such as summing sales for “Laptops” in the “East” region.
- Summing Financial Data: DSUM can be used to sum financial data (e.g., expenses, income) based on conditions, such as summing expenses for a specific month or year.
Example with Multiple Criteria
Suppose you want to sum the Sales for “Tablets” in the “East” region. You would set up the criteria range like this:
| Product | Region |
|---|---|
| Tablet | East |
Then, use the formula:
=DSUM(A1:D6, "Sales", F1:F2)
This will return the sum of sales for “Tablets” in the “East” region, which would be 2000 + 1800 = 3800.
Tips
- Criteria Range: The criteria range should include the column headers from the database, and the condition(s) should be below them.
- Multiple Criteria: You can define multiple criteria in the criteria range to apply multiple conditions for filtering the data. For example, you could sum the sales for a specific product and region by including both conditions in the criteria range.
- Named Ranges: Consider using named ranges for your database and criteria to improve readability and ease of management in complex spreadsheets.
- Error Checking: If you’re getting a result of
0, check the criteria range to ensure that it is correctly defined and that there are matching records in the database.
Common Errors
- #NAME?: This error occurs if the field name is invalid or misspelled.
- #VALUE!: This error occurs if the criteria range is not correctly defined or if there is an issue with the data format.
- 0: This is not an error, but it occurs if no records meet the specified criteria.
Summary
The DSUM function is used to sum the values in a specified field (column) of a database based on conditions defined in a criteria range. It is useful for summing data for specific subsets of data, such as sales for a specific product or region. DSUM is part of Excel’s database functions and allows for complex data analysis using multiple conditions to filter the data before summing it.