Skip to content

xlstream-eval: fix COUNTIF/SUMIF with "=value" criteria returning 0#184

Merged
cilladev merged 1 commit into
mainfrom
fix/countif-equals-criteria
Jun 1, 2026
Merged

xlstream-eval: fix COUNTIF/SUMIF with "=value" criteria returning 0#184
cilladev merged 1 commit into
mainfrom
fix/countif-equals-criteria

Conversation

@cilladev

@cilladev cilladev commented Jun 1, 2026

Copy link
Copy Markdown
Owner

Fixes: #141

Problem

COUNTIF(A2:A6,"=yes") returns 0 instead of 3. Excel supports "=value" as criteria syntax meaning "equals value". Affects SUMIF, AVERAGEIF, COUNTIFS, SUMIFS, AVERAGEIFS, MINIFS, MAXIFS.

Fix

Two root causes:

  1. extract_static_criteria passes the raw "=yes" string as the composite key, but the prelude stores cell values without the = prefix (e.g. "yes"), so the direct hash lookup misses.
  2. try_operator_criteria early-returns None when all criteria are Equals, preventing the fallback scan from matching.

Changes

  • multi_conditional.rs: strip leading = in extract_static_criteria so composite keys match prelude entries
  • prelude.rs: remove the all-Equals guard from try_operator_criteria (now always returns Value, not Option<Value>)
  • prelude.rs: simplify get_multi_conditional call site (no Option unwrap needed)

Test plan

  • Conformance fixture with 8 formulas: COUNTIF, SUMIF, AVERAGEIF, COUNTIFS, SUMIFS with "=value", plain "value", numeric "=10", and mixed criteria
  • cargo test -p xlstream-eval --test conformance passes (85 tests, 0 failures)
  • cargo test -p xlstream-eval passes (no regressions)
  • make check passes

Closes #141

@cilladev cilladev merged commit 3a63327 into main Jun 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COUNTIF/SUMIF with "=value" criteria always returns 0

1 participant