DATABASE Function
D-functions calculate on database rows that match a criteria range, using a shared (database, field, criteria) signature.
Syntax
Parameters
| Parameter | Description | Required |
|---|---|---|
| database | The range of cells that makes up the list or database, including the header row as its first row. Each column is a field and each following row is a record. | Required |
| field | The column to use in the calculation. Supply the column label in quotes (e.g. "Yield") or the column's 1-based position within the database (e.g. 4). | Required |
| criteria | The range of cells that contains the conditions, including a header row that matches database column names and at least one condition row beneath it. A record matches only if it satisfies every condition in a given criteria row; multiple criteria rows are treated as OR. | Required |
Basic Example
Sum the Yield of apple trees taller than 10 using the shared D-function pattern
=DSUM(A1:E7, "Yield", A9:B10)The criteria range A9:B10 holds Tree = Apple and Height > 10; only two records match (Yield 14 and 10), which sum to 24.
Advanced Examples
Example 1: How the criteria range works
A small orchard tableThe database is A1:E7 with headers Tree, Height, Age, Yield, Profit. The criteria block A9:B10 reuses two of those headers so the function knows which columns to filter on.
=DAVERAGE(A1:E7, "Yield", A9:B10)Example 2: Multiple criteria rows act as OR
Find tall apples OR any cherry treeBuild a criteria range with two condition rows: row one is Tree=Apple, Height>10; row two is Tree=Cherry. Records matching either row are included.
=DCOUNT(A1:E7, "Yield", A9:B11)How DATABASE Works
Each D-function first filters the database rows so that only records matching the criteria range remain. It then applies its specific calculation (sum, average, count, max, min, product, or a statistic) to the values in the specified field column of those matching records. Filtering uses the same rules as Excel's advanced filter: criteria on the same row are AND-ed, criteria on different rows are OR-ed, and operators such as >, <, >=, <=, <>, and wildcards (*, ?) are supported.
Important Notes & Limitations
The criteria header labels must exactly match the database headers or the condition is ignored.
Field names with spaces or special characters must be quoted; an unquoted bare column name in the formula will error.
DCOUNT only counts numeric cells, while DCOUNTA counts any non-blank cell, so they can return different results.
Common Errors & Fixes
#VALUE!The field argument is a text column name not enclosed in quotes, or the criteria range has no header.Fix: Wrap the field name in double quotes and ensure the criteria range includes a header row.
Wrong or zero resultCriteria headers do not match database headers, so no rows are filtered.Fix: Make the criteria header text identical to the database column name.
Download Practice File
DATABASE
databasePractice DATABASE with Real Data
Download a sample CSV file with pre-populated data and practice exercises for the DATABASE function. Works in both Excel and Google Sheets.
File format: CSV (comma-separated values) - opens in Excel, Google Sheets, and all spreadsheet apps