Skip to content

Return #VALUE! for text and the error itself for an error in FILTER's conditions (HF-591) - #1891

Merged
Tobiadefami merged 6 commits into
developfrom
fix/hf-591-filter-include-errors
Nov 19, 2026
Merged

Tobiadefami merged 6 commits into
developfrom
fix/hf-591-filter-include-errors

Conversation

@Tobiadefami

@Tobiadefami Tobiadefami commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Context

FILTER treated text and errors in its conditions (the include argument) as FALSE and dropped those rows without a sign. Microsoft Excel returns #VALUE! for text and returns an error as is. With 1, 2 in A1:A2 and TRUE, "x" in B1:B2, =FILTER(A1:A2, B1:B2) returned 1 where Excel returns #VALUE!.

The condition loop in ArrayPlugin.filter() now:

  • returns #VALUE! for any text, before boolean coercion. coerceScalarToBoolean reads "TRUE", "FALSE" and "" as booleans, but Excel rejects them in a condition.
  • returns an error from a condition as is.
  • stops at the first text or error in reading order, which matches Excel when a condition holds several.

These checks apply to include only. Excel's third argument is if_empty; the further conditions HyperFormula accepts are its own extension, so they keep dropping rows with text or an error, and a row still stops at its first condition that is not TRUE. Blank cells, FALSE and 0 still drop a row, and other numbers keep it, as before.

Breaking change. Rows that FILTER used to drop, such as a condition column of =IF(B1>0, TRUE(), ""), now make it return #VALUE!, so this targets 4.0.0. The changelog entry is under Changed, and a section in migration-from-3.x-to-4.0.md lists the cases and the fix: return FALSE() instead of "". #1848, #1889 and #1890 create the same guide, so each PR that merges after the first one combines the sections.

How did you test your changes?

  • npx jest in hyperformula/ with the paired hyperformula-tests branch fix/hf-591-filter-include-errors (handsontable/hyperformula-tests#120), after merging the current develop: 539 suites, 8,377 tests passed, 3 skipped.
  • The 12 new FILTER cases: 9 fail on develop and pass here. The other three (blank cells and numbers, and two on further conditions) pass on both, since that behaviour doesn't change.
  • npm run docs:build passes, including the new migration guide.
  • npm run verify:typings, and eslint on the changed file: no errors and no new warnings.

AI assistance

Claude Code wrote the code, tests and changelog entry, and ran the Excel comparison.

Compatibility with Excel and Google Sheets

Checked in Microsoft Excel Online and Google Sheets, with 1, 2, 3 in A1:A3 and the conditions in B1:B3. Google Sheets drops a row with text or an error in include, as HyperFormula 3.x did:

Formula Excel Google Sheets HyperFormula
=FILTER(A1:A3, B1:B3), B1:B3 = TRUE, "x", FALSE #VALUE! 1 #VALUE!
=FILTER(A1:A3, B1:B3), B1:B3 = TRUE, =1/0, FALSE #DIV/0! 1 #DIV/0!
=FILTER(A1:A3, B1:B3), B1:B3 = "x", =1/0, TRUE #VALUE! 3 #VALUE!
=FILTER(A1:A3, B1:B3), B1:B3 = =1/0, "x", TRUE #DIV/0! 3 #DIV/0!
=FILTER(A1:A3, B1:B3), B1:B3 = =NA(), =1/0, TRUE #N/A 3 #N/A
=FILTER(A1:A3, B1:B3), B1:B3 = ="TRUE", ="1" or ="" first #VALUE! 1, 2, 3 for ="TRUE" #VALUE!
=FILTER(A1:A3, B1:B3), B1:B3 = FALSE, FALSE, =NA() #N/A #N/A (no match) #N/A
=FILTER(A1:A3, B1:B3>0), B2 = =1/0 #DIV/0! The row is dropped #DIV/0!
=FILTER(A1:A3, B1:B3), B1:B3 = blank, 2, 0 2 2 2
=FILTER(A1:A3, B1:B3), B1:B3 = TRUE, -1, 0.5 1, 2, 3 1, 2, 3 1, 2, 3
=FILTER(A1:C1, A2:C2), A2:C2 = TRUE, "x", FALSE #VALUE! 1 #VALUE!
=SUM(FILTER(A1:A2, B1:B2, C1:C2)), B1:B2 = FALSE, TRUE, C1:C2 = =1/0, TRUE 2 2 2

Public API changes

None. FILTER returns #VALUE! or an error where it used to drop rows (see Context).

Out of scope and follow-ups

None.

Types of changes

  • Breaking change (existing functionality no longer works as before) – agreed with the maintainers
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues

  1. HF-591

Checklist

🤖 Generated with Claude Code


Note

Low Risk
Scoped to FILTER condition handling in ArrayPlugin; no public API changes, but formulas that previously filtered past text or error conditions will now surface Excel-style errors.

Overview
FILTER now matches Microsoft Excel when evaluating include conditions: any text in a condition cell immediately yields #VALUE! (text is no longer coerced via coerceScalarToBoolean, so strings like "TRUE" are rejected too), and CellError values from a condition are returned as-is instead of being treated as FALSE.

The changelog records the fix (#1891). Numeric/boolean filtering behavior is unchanged—blank cells, FALSE, and 0 still exclude rows.

Reviewed by Cursor Bugbot for commit 6c8117d. Configure here.

Tobiadefami and others added 2 commits November 12, 2026 20:27
… conditions

FILTER treated text and errors in a condition as FALSE and dropped the
row. Microsoft Excel returns #VALUE! for text (even "TRUE", "1" or
empty text) and returns an error as is, whichever comes first, even when
no row would be kept. Every condition of a row is now checked, so an
error in a later condition is no longer skipped when an earlier one is
FALSE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
hyperformula-docs fbc8162 Commit Preview URL

Branch Preview URL
Nov 19 2026, 09:36 AM

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Performance comparison of head (fbc8162) vs base (293c595)

                                     testName |    base |    head | change
--------------------------------------------------------------------------
                                      Sheet A |  507.87 |  510.17 | +0.45%
                                      Sheet B |  166.76 |  168.01 | +0.75%
                                      Sheet T |  144.93 |  145.01 | +0.06%
                                Column ranges |  531.54 |   530.3 | -0.23%
                                Sorted lookup | 15464.9 | 16062.1 | +3.86%
Sheet A:  change value, add/remove row/column |   18.98 |   18.82 | -0.84%
 Sheet B: change value, add/remove row/column |   145.3 |  147.66 | +1.62%
                   Column ranges - add column |  185.77 |  183.52 | -1.21%
                Column ranges - without batch |  526.81 |   510.8 | -3.04%
                        Column ranges - batch |  128.73 |  127.59 | -0.89%

@handsontable-pr-review handsontable-pr-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Medium risk: Adds new core array functions (CHOOSECOLS/CHOOSEROWS/TAKE) and changes FILTER semantics in the interpreter plugin; wrong spill-size prediction or error results would surface directly in user formulas.

Incremental review: 2 potential issue(s).

hyperformula/src/interpreter/plugin/ArrayPlugin.ts:503

CHOOSEROWS on whole-row source returns #SPILL! even when nested

Medium severity

chooseAlongAxis unconditionally returns a #SPILL! error whenever the source is a whole-row range and the formula is not in column A. When the result is consumed by an enclosing function (e.g. =SUM(CHOOSEROWS(1:1, 1)) placed in column B), no spill is needed and Excel computes the value, but HyperFormula returns #SPILL!. The parallel CHOOSECOLS case deliberately keeps the unbounded size so nested evaluation still works, so this asymmetry produces a wrong result on a realistic path.

Suggestion: Only return the SPILL error when the result is actually spilled at top level (or rely on array-space validation as the CHOOSECOLS path does), so nested consumers can evaluate the selection.

hyperformula/src/interpreter/plugin/ArrayPlugin.ts:569

isUnpredictedSize guard applied only to CHOOSEROWS, not CHOOSECOLS

Low severity

chooseArraySize rejects unpredicted 1x1-predicted sources (named expressions, function results) only when axis === 'rows'. For CHOOSECOLS the same source keeps chosenLength = 1 and keptLength = 1, so CHOOSECOLS(namedExpr, 2) is rejected with an invalid size even though the real range is wider and the call is valid, and CHOOSECOLS(namedExpr, 1) gets a 1x1 predicted size that can mismatch the actual result height. The two axes should be handled consistently.

Suggestion: Apply the isUnpredictedSize check for both axes, or handle the unpredicted-source case for columns the same way as for rows.

Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).

@marcin-kordas-hoc marcin-kordas-hoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran function-filter.spec.ts at 9e81f52 with hyperformula-tests at 1051d60bae: 19 tests pass and 10 fail on the develop engine, as the description says. Removing the text check fails 6 tests, ignoring the error fails 6, and putting break back fails 1. I re-measured four of your cases and a ="TRUE" variant in Excel Online with the conditions in cells, and this branch matches all five; develop differs in four.

Comment thread CHANGELOG.md Resolved
Tobiadefami and others added 2 commits November 18, 2026 16:25
Excel's third FILTER argument is if_empty; the conditions after include are
HyperFormula's own extension, so they keep dropping rows with text or an
error, and a row stops at its first condition that is not TRUE again.

The change to include drops rows no longer, so it is listed under Changed
as a breaking change, with a section in the 3.x to 4.0 migration guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@marcin-kordas-hoc marcin-kordas-hoc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At 5ec67d2 with hyperformula-tests at 5446ec8e6f, function-filter.spec.ts passes 20/20, and 9 tests fail on the develop engine. Dropping the text check fails 6 tests, dropping the error return fails 5, and applying either check to every condition fails 1. The if_empty layout from my last review gives 2 here, as in Excel Online and on develop. The five include cases from that review and an =IF(...,TRUE(),"") column match Excel Online, and develop differs in five of the six. The entry is under Changed, and the guide section has the same shape as the ones in #1889 and #1890.

Comment thread docs/guide/migration-from-3.x-to-4.0.md Resolved
…include-errors

# Conflicts:
#	CHANGELOG.md
#	docs/guide/migration-from-3.x-to-4.0.md
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.51%. Comparing base (293c595) to head (fbc8162).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1891   +/-   ##
========================================
  Coverage    97.51%   97.51%           
========================================
  Files          210      210           
  Lines        17133    17138    +5     
  Branches      3924     3926    +2     
========================================
+ Hits         16707    16712    +5     
  Misses         418      418           
  Partials         8        8           
Files with missing lines Coverage Δ
hyperformula/src/interpreter/plugin/ArrayPlugin.ts 99.72% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Tobiadefami
Tobiadefami merged commit f63be1a into develop Nov 19, 2026
36 checks passed
@Tobiadefami
Tobiadefami deleted the fix/hf-591-filter-include-errors branch November 19, 2026 09:57
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.

2 participants