The DSUM
function in Excel is used to calculate the sum of values in a specified field (column) of a database that meet certain criteria. It's part of Excel's database functions which operate on a range treated as a database.
Syntax
excelDSUM(database, field, criteria)
- database: The range of cells that makes up the database. The first row should contain the column headers.
- field: Indicates which column to use in the function. This can be a column label enclosed in double quotation marks (e.g., "Age") or a number that represents the column's position in the list (e.g., 2 for the second column).
- criteria: The range of cells that contains the conditions you specify.
Example
Let's consider an example to understand how the DSUM
function works.
Example Database
Suppose you have the following data in cells A1:D6:
Name | Age | Gender | Salary |
---|---|---|---|
John | 28 | Male | 50000 |
Alice | 34 | Female | 65000 |
Bob | 45 | Male | 45000 |
Carol | 28 | Female | 55000 |
Dave | 34 | Male | 60000 |
Criteria
You want to sum the salaries of all males. Place the criteria in cells F1:G2:
Gender |
---|
Male |
DSUM Formula
- In cell H1, enter the formula:
This will outputexcel=DSUM(A1:D6, "Salary", F1:F2)
155000
.
Here's the step-by-step explanation:
- database:
A1:D6
(the entire range of the database including headers). - field:
"Salary"
(the column from which to sum the values). - criteria:
F1:F2
(the range where the criteria is specified).
The DSUM
function looks at the "Salary" column and sums the values where the "Gender" is "Male".
Another Example with Multiple Criteria
Suppose you want to sum the salaries of males aged 34. You can add more criteria like this in cells F1:G3:
Gender | Age |
---|---|
Male | 34 |
- In cell H2, enter the formula:
This will outputexcel=DSUM(A1:D6, "Salary", F1:G3)
60000
.
Here's the explanation for this second example:
- database:
A1:D6
. - field:
"Salary"
. - criteria:
F1:G3
(the range where the criteria for "Gender" and "Age" are specified).
The DSUM
function sums the "Salary" values where the "Gender" is "Male" and the "Age" is 34.
Summary
The DSUM
function is powerful for summing values in a database that match specific criteria. It can handle multiple criteria across different columns, making it versatile for data analysis tasks.
No comments:
Post a Comment