The DSUM function in Excel is a powerful tool used for database operations. It allows users to efficiently calculate the sum of values in a specific field of records that meet defined criteria, making it invaluable for data analysis and reporting.
Syntax
DSUM(database, field, criteria)
- database: The range of cells that makes up the database, including headers.
- field: The name (within quotation marks) or index number of the column that contains the values to be summed.
- criteria: The range of cells that specify the conditions that must be met for records to be included in the sum.
Example #1
DSUM(A1:C10, "Sales", E1:E2)
This function calculates the total sales from the database in the range A1:C10 for records that match the criteria described in E1:E2. For example, if E1 contains “Region” and E2 contains “North”, the outcome could be $1,500 if that’s the sum for the North region’s sales.
Example #2
DSUM(A1:C10, 2, F1:F2)
Here, the function sums the values from the second column of the database in A1:C10 based on the criteria in F1:F2. If F1 is “Product” and F2 is “Widget”, resulting in a total of $800 for all widgets sold, that would be the output.
Example #3
DSUM(A1:C10, "Quantity", G1:G2)
This function sums the entries in the “Quantity” column based on the conditions specified in G1:G2. For instance, if G1 states “Status” and G2 says “Active”, producing a result of 300 active items sold, that would be shown as the result.
Error handling
- VALUE!: This error occurs when the field parameter is not valid or if the criteria range is empty or incorrectly referenced.
- NAME?: This error appears when the specified field name does not exist in the database.
- NUM!: This indicates that the field parameter is not a valid column number when using the index number option.