Our 10 featured functions
COUNTIFS
Matches all 14 recorded answers
Recorded: 14 workbook cells. How we measure this · See the Rust code
Local names in 40 languages
| Language | Name in Excel |
|---|---|
| Arabic | COUNTIFS |
| Bulgarian | COUNTIFS |
| Czech | COUNTIFS |
| Danish | TÆL.HVISER |
| German | COUNTIFS |
| Greek | COUNTIFS |
| English (Australia) | COUNTIFS |
| English (United Kingdom) | COUNTIFS |
| English (United States) | COUNTIFS |
| Spanish | CONTAR.SI.CONJUNTO |
| Estonian | COUNTIFS |
| Finnish | LASKE.JOS.JOUKKO |
| French | NB.SI.ENS |
| Hebrew | COUNTIFS |
| Croatian | COUNTIFS |
| Hungarian | DARABHATÖBB |
| Indonesian | COUNTIFS |
| Italian | COUNTIFS |
| Japanese | COUNTIFS |
| Korean | COUNTIFS |
| Lithuanian | COUNTIFS |
| Latvian | COUNTIFS |
| Norwegian | ANTALL.HVIS, ANTALL.HVIS.SETT |
| Dutch | AANTALLEN.ALS |
| Polish | LICZ.WARUNKI |
| Portuguese (Brazil) | COUNTIFS |
| Portuguese (Portugal) | CONTAR.SE.S |
| Romanian | COUNTIFS |
| Russian | СЧЁТЕСЛИМН |
| Slovak | COUNTIFS |
| Slovenian | COUNTIFS |
| Serbian (Latin) | COUNTIFS |
| Swedish | ANTAL.OMF |
| Thai | COUNTIFS |
| Turkish | ÇOKEĞERSAY işlevi |
| Ukrainian | COUNTIFS |
| Vietnamese | COUNTIFS |
| Chinese (Simplified) | COUNTIFS |
| Chinese (Hong Kong) | COUNTIFS |
| Chinese (Traditional) | COUNTIFS |
Names from Microsoft's support site.
What it does
COUNTIFS(criteria_range1, criteria1, [criteria_range2], [criteria2], ...)
COUNTIFS(criteria_range1,criteria1,[criteria_range2,criteria2],...) counts positions where all paired conditions hold. It combines conditions with AND. Up to 127 range/criterion pairs are documented. The ranges align by their row and column offsets and need not be adjacent on the sheet.
Try it
Use these four rows:
| Row | B: amount | C: region |
|---|---|---|
| 2 | 4 | east |
| 3 | 11 | east |
| 4 | 7 | west |
| 5 | 13 | east |
=COUNTIFS(B2:B5,">=10",C2:C5,"east") returns 2, for rows three and five. Repeating a range creates an interval: =COUNTIFS(B2:B5,">=7",B2:B5,"<=11") returns 2.
Adding separate counts implements an OR only when overlap is handled. Here COUNTIF(B2:B5,">=10")+COUNTIF(C2:C5,"east") is five, because rows three and five are counted twice. Subtract their intersection, the first COUNTIFS result, to get three distinct rows meeting either condition.
Quirks
Every criteria range must have the same row and column dimensions as the first. Equal total cell counts in different shapes are not enough. The current implementation returns #VALUE! for a shape mismatch before reading any criterion.
Conditions on the same range still use AND. For example, ">=7" and "<=11" define an inclusive interval; the pair ">=10" and "<5" cannot match one numeric value. For OR, count a union without double-counting its overlap.
A criterion referencing an empty cell is treated as zero. This does not make every blank tested cell equivalent to zero under every predicate. Text criteria retain case-insensitive matching and ?, *, ~ wildcard syntax; preserve leading and trailing spaces when their presence is meaningful.
How to implement
- Validate the argument pairs and resolve all range references. Check row and column dimensions before reading criteria or range values, preserving the current error order.
- Read each criterion once and compile the typed COUNTIF predicate: operator, operand kind and any wildcard tokens.
- Align ranges by offset inside their own rectangles. At a position, combine every predicate’s verdict with AND. A known false verdict rules that position out; do not add independent per-range counts.
- Increment once for each position satisfying all conditions. Return one numeric count after visiting the aligned positions.
In the main example, B2/C2 fails the amount condition, B3/C3 passes both, B4/C4 fails, and B5/C5 passes both, giving two. For the interval example, seven and eleven pass both tests.
The current sparse implementation keeps verdicts for visited cells and counts matching blank positions in bulk, so whole-column references need not allocate a Boolean entry for every worksheet cell. It preserves unresolved verdicts and refuses only when one can affect the count. Copying its supported predicates is an implementation route; the explicitly unmodeled text, array and collation cases still need evidence before coverage can be extended.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
COUNTIFS · 1 lines · calc-func/src/catalogue/conditional.rs on GitHubconditional(COUNTIFS, "COUNTIFS", (2, 254), COUNT_PAIRS, countifs)
countifs · 11 lines · calc-func/src/catalogue/conditional.rs on GitHub/// COUNTIFS: the positions at which every criteria range's cell meets its criterion.
fn countifs(
arguments: &[CalcValue],
services: &mut EvalServices<'_>,
) -> Result<CalcValue, FunctionFault> {
let site = Site::new(COUNTIFS, services);
Site::finish(pairs(&site, arguments, services, false).and_then(|plan| {
let conditions = plan.read_conditions(&site, services)?;
count(&site, &conditions, plan.size)
}))
}
Kernels shared with other functions
readercatalogue/aggregateread_referencecatalogue/aggregatenumberscatalogue/comparisonin_bandcatalogue/comparisonRounded::upcatalogue/comparisonRoundings::ofcatalogue/comparisonRoundings::disjointcatalogue/comparisontextscatalogue/comparisoncomparecatalogue/comparison/collationweighedcatalogue/comparison/collationmeasured_iteration_extensioncatalogue/comparison/collationtablecatalogue/comparison/sort_keydecode64catalogue/comparison/sort_keyReader::bytecatalogue/comparison/sort_keyReader::varintcatalogue/comparison/sort_keyReader::donecatalogue/comparison/sort_keyin_rangescatalogue/comparison/sort_keybuildcatalogue/comparison/sort_keyhan_basecatalogue/comparison/sort_keyderivecatalogue/comparison/sort_keyshared_jamo_tailscatalogue/comparison/sort_keyordinary_jamo_prefixcatalogue/comparison/sort_keyindependent_jamo_suffixcatalogue/comparison/sort_keyjamo_leading_primarycatalogue/comparison/sort_keyleading_ordercatalogue/comparison/sort_keyBefore::separate_specialcatalogue/comparison/sort_keyGathered::kanacatalogue/comparison/sort_keyGathered::unitcatalogue/comparison/sort_keypartscatalogue/comparison/sort_keydiacritic_ordercatalogue/comparison/sort_keydiacriticscatalogue/comparison/sort_keyconditionalcatalogue/conditionalRange::shapecatalogue/conditionalrangecatalogue/conditionalpairscatalogue/conditionalPlan::read_conditionscatalogue/conditionalrowcatalogue/conditionalcountcatalogue/conditionaloffsetcatalogue/conditionalread_rangecatalogue/conditionalverdictscatalogue/conditionalusedcatalogue/conditionalMatch::ofcatalogue/conditionalMatch::negatedcatalogue/conditionalOp::holdscatalogue/conditionalOp::is_equalitycatalogue/conditionalspellscatalogue/conditionalcriterioncatalogue/conditionalrankcatalogue/conditionalcriterion_textcatalogue/conditionaldecidedcatalogue/conditionalCriterion::verdictcatalogue/conditionalequalitycatalogue/conditionalis_surrogatecatalogue/conditionalwildcardcatalogue/conditionallow32decimalNatural::from_u64decimalNatural::pow10decimalNatural::normalizedecimalNatural::is_zerodecimalNatural::mul_add_smalldecimalNatural::times_pow10decimalNatural::times_pow5decimalNatural::times_pow2decimalExactDecimal::binarydecimaltextported/text_kernelstext_from_strported/text_kernelsfold_unitported/text_kernelspush_singleton_or_originalported/text_kernelspush_lowerported/text_kernelslowerported/text_kernels
Argument and result plumbing
operandcoerce
No implementation has been published with a Handbook test suite for this function.
Version differences
No same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.
Alternatives
COUNTIF handles one condition; SUMIFS sums matching amounts; FILTER exposes the matching records.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents