The DSUM function in Google Sheets is a powerful tool that allows users to calculate the sum of specific values from a data range that resembles a database table. By utilizing a SQL-like query, DSUM provides a flexible way to perform calculations based on certain criteria, making it an essential function for data analysis and reporting.
Syntax
DSUM(database, field, criteria)
- database: The range of cells that contains the data you want to analyze. This range should include the column headers.
- field: The column from which you want to sum the values. This can be specified as a text string (the column header) or as a number (the column index).
- criteria: The range that defines the conditions for which the values will be summed. This range should include the same column header as the database.
Example #1
DSUM(A1:C10, "Sales", E1:E2)
This function adds up all the values in the “Sales” column, considering only those records that meet the specified conditions in the criteria range E1:E2. For instance, if the criteria are:
– Region: “North”
– Month: “January”
The result might be $2,500 based on the data in the specified range.
Example #2
DSUM(A1:C10, 2, E1:E2)
Here, the function calculates the sum of the second column in the database, which is assumed to be “Revenue.” Only the entries that fulfill the criteria in E1:E2 will be included. If the criteria specify a yearly threshold, the result could be $3,000.
Example #3
DSUM(A1:C10, "Costs", E1:E3)
In this example, the DSUM function computes the totals from the “Costs” column, filtered by the conditions defined in E1 through E3. If the criteria filter out all relevant records, the output will showcase the total costs incurred, possibly summing to $1,200 based on non-empty matches.
Error handling
- VALUE!: This error indicates that at least one of the arguments is of the wrong type, such as when the database range does not reference valid cell references.
- N/A: This occurs if the specified field is not found in the database range, whether due to a misspelling or incorrect reference.
- REF!: This error emerges when one of the range references is invalid or has been deleted, rendering the entire calculation unworkable.