Contact

DSUM Function (LibreOffice Calc)

Database Intermediate LibreOffice Calc Introduction not established

The DSUM function sums numeric values in a database column that match a set of criteria. It is part of the database function family and supports structured, criteria-based filtering.

Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked

Availability and version history

  • Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
  • Availability: Supported in LibreOffice 26.8.1.1, verified against its function registry. This identifies a supported release, not a final working version.
  • Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
  • Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
The **DSUM** function sums numeric values in a database column that match a set of criteria. It is part of Calc’s database function family, which uses structured criteria ranges to filter data before performing calculations. DSUM is ideal for conditional summation in tabular datasets without needing SUMIFS or array formulas.

What the DSUM Function Does

  • Sums numeric values in a specified database column
  • Applies criteria-based filtering using a criteria range
  • Supports multiple criteria columns
  • Supports AND/OR logic via criteria layout
  • Works with structured database ranges

It is designed to be precise, structured, and ideal for database-style summation.

Syntax

DSUM(database; field; criteria)

Arguments

  • database:
    A range where the first row contains column labels.

  • field:
    The column to sum.

    • Use column label in quotes (recommended)
    • Or use column index (1 = first column)
  • criteria:
    A range containing column labels and one or more criteria rows.

Basic Examples

Assume a table in A1:C6:

A (Name) B (Age) C (Score)
John 25 80
Mary 30 90
Alex 22 70
John 28 85
Mary 35 88

Criteria in E1:F2:

Age Score
>25 >80

Sum Score values matching criteria

=DSUM(A1:C6; "Score"; E1:F2)

Returns 263 (90 + 85 + 88).

Sum Age values matching criteria

=DSUM(A1:C6; "Age"; E1:F2)

Returns 93 (30 + 28 + 35).

Sum using field index

=DSUM(A1:C6; 3; E1:F2)

Sums numeric values in column 3 (Score).

Advanced Examples

Sum entries where Name = “John”

Criteria:

Name
John

Formula:

=DSUM(A1:C6; "Score"; E1:E2)

Sum entries where Age is between 25 and 30

Criteria:

Age
>=25
<=30

Formula:

=DSUM(A1:C6; "Score"; E1:E3)

OR logic (multiple rows)

Criteria:

Age Score
>30
>85

Formula:

=DSUM(A1:C6; "Score"; E1:F3)

Sum entries where Name begins with “M”

Criteria:

Name
M*

Formula:

=DSUM(A1:C6; "Score"; E1:E2)

Sum entries with dynamic criteria

=DSUM(A1:C6; "Score"; H1:I2)

Where H1:I2 is generated by formulas.

Sum only positive values

Criteria:

Score
>0

Formula:

=DSUM(A1:C6; "Score"; E1:E2)

Sum entries where Score is non-blank

Criteria:

Score
<>""

Formula:

=DSUM(A1:C6; "Score"; E1:E2)

Edge Cases and Behavior Details

DSUM sums only numeric values

Text, blanks, and errors are ignored.

field can be:

  • Column label
  • Column index
  • Cell containing label

criteria must include column labels

Exact match required.

criteria supports:

  • Comparison operators
  • Wildcards
  • Multiple rows (OR)
  • Multiple columns (AND)

Empty criteria → sums all numeric values

DSUM of an error in database → error ignored

DSUM of an error in criteria → error returned

Criteria rows:

  • Each row = OR
  • Each column = AND

Common Errors and Fixes

DSUM returns 0 unexpectedly

Cause:

  • Criteria labels don’t match database labels
  • Criteria misaligned
  • Field name misspelled
  • Criteria row blank

Fix:

  • Ensure labels match exactly
  • Ensure criteria range includes labels

Err:502 — Invalid argument

Occurs when:

  • field is invalid
  • database range malformed

Wrong sum due to text values

DSUM ignores non-numeric entries.

Criteria not applied

Cause:

  • Criteria labels not identical to database labels

Best Practices

  • Use column labels instead of index numbers
  • Keep criteria ranges small and clearly labeled
  • Use wildcards for flexible text matching
  • Use multiple criteria rows for OR logic
  • Use multiple criteria columns for AND logic
  • Use DSUM instead of SUMIFS when you need database-style criteria
  • Use FILTER (modern Calc) for dynamic extraction
DSUM is your structured summation engine — perfect for database-style filtering, multi-criteria logic, and clean, readable conditional summation.
  • Use DCOUNT or DCOUNTA for counting
  • Use DAVERAGE for conditional averages
  • Use DMAX and DMIN for conditional extrema
  • Use DGET for retrieving a single matching record
  • Use SUMIFS for simpler criteria without database structure
  • Use FILTER for dynamic row extraction

By mastering DSUM and its companion database functions, you can build powerful, structured, and criteria-driven data workflows in LibreOffice Calc.