DCOUNT Function (LibreOffice Calc)
The DCOUNT function counts numeric entries in a database column that match a set of criteria. It is part of the database function family and supports structured, criteria-based filtering.
Compatibility
▾| Excel | ✔ |
| Gnumeric | ✔ |
| Google_sheets | ✔ |
| Libreoffice | ✔ |
| Numbers | ✖ |
| Onlyoffice | ✔ |
| Openoffice | ✔ |
| Wps | ✔ |
| Zoho | ✔ |
What the DCOUNT Function Does â–¾
- Counts 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 counting.
Syntax â–¾
DCOUNT(database; field; criteria)
Arguments
-
database:
A range of cells where the first row contains column labels. -
field:
The column to count.- 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 |
Count numeric values in Score that match criteria
=DCOUNT(A1:C6; "Score"; E1:F2)
Returns 3.
Count numeric values in Age column
=DCOUNT(A1:C6; "Age"; E1:F2)
Returns 3.
Count using field index
=DCOUNT(A1:C6; 3; E1:F2)
Counts numeric values in column 3 (Score).
Advanced Examples â–¾
Count entries where Name = “John”
Criteria:
| Name |
|---|
| John |
Formula:
=DCOUNT(A1:C6; "Score"; E1:E2)
Count entries where Age is between 25 and 30
Criteria:
| Age |
|---|
| >=25 |
| <=30 |
Formula:
=DCOUNT(A1:C6; "Age"; E1:E3)
Count entries with OR logic (multiple rows)
Criteria:
| Age | Score |
|---|---|
| >30 | |
| >85 |
Formula:
=DCOUNT(A1:C6; "Score"; E1:F3)
Count entries where Name begins with “M”
=DCOUNT(A1:C6; "Score"; E1:E2)
Criteria:
| Name |
|---|
| M* |
Count numeric values only (ignores text)
If Score column contains text like “N/A”, DCOUNT skips it.
Count entries with multiple criteria columns
=DCOUNT(A1:C6; "Score"; E1:G2)
Count entries with dynamic criteria
=DCOUNT(A1:C6; "Age"; H1:I2)
Where H1:I2 is generated by formulas.
Edge Cases and Behavior Details â–¾
DCOUNT counts only numeric values
Text, blanks, and errors are ignored.
field can be:
- Column label (preferred)
- Column index (1-based)
- A cell reference containing the label
criteria must include column labels
If labels don’t match exactly → no filtering applied.
criteria supports:
- Comparison operators: >, <, >=, <=, <>
- Wildcards: * and ?
- Text matches
- Multiple criteria rows (OR logic)
- Multiple criteria columns (AND logic)
criteria range can be anywhere on the sheet
criteria rows:
- Each row = OR
- Each column = AND
Empty criteria → counts all numeric values
DCOUNT of an error in database → error ignored
DCOUNT of an error in criteria → error returned
Common Errors and Fixes â–¾
DCOUNT returns 0 unexpectedly
Cause:
- Column labels don’t match
- Criteria misaligned
- Criteria row blank
- Field name misspelled
Fix:
- Ensure labels match exactly
- Ensure criteria range includes labels
Err:502 — Invalid argument
Occurs when:
- field is invalid
- database range malformed
Wrong count due to text values
DCOUNT 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 DCOUNTA when counting text + numbers
- Use DSUM/DAVERAGE for numeric aggregation
Related Patterns and Alternatives â–¾
- Use DCOUNTA to count text + numbers
- Use COUNTIFS for simpler criteria without database structure
- Use DSUM, DAVERAGE, DMAX, DMIN for aggregation
- Use FILTER (modern Calc) for dynamic extraction
- Use REGEX or TEXTAFTER for text-based criteria preprocessing
By mastering DCOUNT and its companion database functions, you can build powerful, structured, and criteria-driven data workflows in LibreOffice Calc.