COUNTIF Function (LibreOffice Calc)
The COUNTIF function in LibreOffice Calc counts cells that meet a single condition. This guide explains syntax, operators, wildcards, examples, errors, and best practices.
Verification status: Selected examples were executed in LibreOffice Calc 25.2.3.2. This does not establish that every formula and edge case was tested. 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.
Native-tested visual example: Count tickets matching one status
A team tracks six requests. COUNTIF counts the four rows marked Open, regardless of ticket ID.
Enter this formula in cell E5:
=COUNTIF(B5:B10;"Open")
Expected result: 4. The range B5:B10 contains six status cells. Only four equal Open. The comparison ignores letter case by default.

Real screenshot captured from LibreOffice Calc 25.2.3.2. The selected E5 cell shows the calculated result and the formula bar displays the entered formula.
Download the editable COUNTIF example (.ods) — change the sample input cells and watch the calculation update.
Why it works: The range
B5:B10contains six status cells. Only four equalOpen. The comparison ignores letter case by default. Watch for: For more than one condition, use COUNTIFS rather than adding separate COUNTIF results.
Verification: Example calculated in LibreOffice Calc 25.2.3.2. Screenshot is a genuine application capture, not a mockup.
What the COUNTIF Function Does
- Counts cells that match a single condition
- Supports numeric, text, logical, and wildcard criteria
- Works with comparison operators (
>,<,>=, etc.) - Supports partial text matching
- Works efficiently on large datasets
- Ideal for filtering and data validation
COUNTIF is the foundation of conditional counting in spreadsheets.
Syntax
COUNTIF(range; criteria)
;) to separate arguments.
Criteria Types
COUNTIF supports:
- Numeric comparisons
- Text comparisons
- Wildcards (
*and?) - Logical expressions
- Cell‑based criteria
Examples:
">50"
"<=100"
"apple"
"A*"
"<>" (not equal to empty)
"=" & B1 (criteria from a cell)
Basic Examples
Count values greater than 50
=COUNTIF(A1:A10; ">50")
Count cells equal to a specific number
=COUNTIF(A1:A10; 100)
Count cells equal to text
=COUNTIF(B1:B10; "North")
Count cells not equal to text
=COUNTIF(B1:B10; "<>North")
Count blank cells (alternative to COUNTBLANK)
=COUNTIF(A1:A10; "=")
Count non‑blank cells (alternative to COUNTA)
=COUNTIF(A1:A10; "<>")
Text & Wildcard Examples
Count cells starting with “A”
=COUNTIF(A1:A10; "A*")
Count cells ending with “ing”
=COUNTIF(A1:A10; "*ing")
Count cells containing “car”
=COUNTIF(A1:A10; "*car*")
Count cells with exactly 5 characters
=COUNTIF(A1:A10; "?????")
Advanced Examples
Use a cell reference as the criteria
=COUNTIF(A1:A10; "=" & B1)
Count values between 50 and 100
=COUNTIF(A1:A10; ">=50") - COUNTIF(A1:A10; ">100")
Count text but ignore case
COUNTIF is case‑insensitive by default.
Count case‑sensitive matches
Use SUMPRODUCT:
=SUMPRODUCT(EXACT(A1:A10; "Apple"))
Count dates before a specific date
=COUNTIF(A1:A10; "<" & DATE(2025; 1; 1))
Count errors
=COUNTIF(A1:A10; "#N/A")
Count formulas returning empty strings
=COUNTIF(A1:A10; "=")
Common Errors and Fixes
COUNTIF returns 0 unexpectedly
Possible causes:
- Criteria missing quotes
- Numbers stored as text
- Hidden spaces or non‑breaking spaces
- Wildcards used incorrectly
Fix:
Check with:
=LEN(A1)
COUNTIF does not accept multiple ranges
This is expected.
Use COUNTIFS or SUMPRODUCT for multi‑range logic.
Err:504 — Parameter error
Occurs when:
- Semicolons are incorrect
- Criteria is malformed
- Range is invalid
COUNTIF is slow on large datasets
Use:
- Named ranges
- Helper columns
- COUNTIFS (more optimized)
Best Practices
- Always quote criteria containing operators
- Use wildcards for flexible text matching
- Use COUNTIFS for multi‑condition logic
- Clean imported data before applying criteria
- Use cell references for dynamic criteria
- Avoid overly complex criteria strings
Reproducible example (tested in LibreOffice Calc)
This standalone example was calculated in LibreOffice Calc 25.2.3.2 and matched the expected value. It is a practical cross-check of one usage, not proof that every example elsewhere on this page is correct.
Use this small practice sheet for the ranges referenced in the formula:
| Row | A (Quantity) | B (Amount) | C (Category) |
|---|---|---|---|
| 1 | 1 | 10 | apple |
| 2 | 2 | 20 | pear |
| 3 | 3 | 30 | apple |
| 4 | 4 | 40 | pear |
| 5 | 5 | 50 | apple |
=COUNTIF(C1:C5;"apple")
Expected result: 3.
Count matching categories in a sample table.
If the result differs, check the referenced cells, argument separators and number formatting. For more information, consult the LibreOffice Calc official help.