Skip to content

Database Functions

Database functions perform calculations on a dataset that matches specified criteria. They all share the same structure:

=DFUNCTION(database, field, criteria)
  • database -- A range including column headers (e.g., A1:D100).
  • field -- The column to calculate on, specified as a column header string (e.g., "Sales") or column index (1-based).
  • criteria -- A range with header(s) and condition row(s) defining which records to include.

Criteria Example

If your data has headers in row 1 (Name, Region, Sales), a criteria range might be:

Region Sales
East >500

This selects rows where Region is "East" and Sales is greater than 500.

Functions

Function Syntax Description
DSUM DSUM(database, field, criteria) Sum of matching records
DAVERAGE DAVERAGE(database, field, criteria) Average of matching records
DCOUNT DCOUNT(database, field, criteria) Count of matching records with numeric values
DCOUNTA DCOUNTA(database, field, criteria) Count of matching non-empty records
DMAX DMAX(database, field, criteria) Maximum of matching records
DMIN DMIN(database, field, criteria) Minimum of matching records
DGET DGET(database, field, criteria) Returns the single matching value (errors if 0 or 2+ matches)
DVAR DVAR(database, field, criteria) Variance of matching records (sample)
DSTDEV DSTDEV(database, field, criteria) Standard deviation of matching records (sample)

Example

Given a table in A1:C20 with headers Product, Category, Revenue:

=DSUM(A1:C20, "Revenue", E1:E2)

Where E1 contains Category and E2 contains Electronics -- returns the total revenue for all electronics products.