Repository navigation
Return #VALUE! for text and the error itself for an error in FILTER's conditions (HF-591) - #1891
Conversation
… 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>
Deploying with
|
| 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 |
Performance comparison of head (fbc8162) vs base (293c595) |
…include-errors # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
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.
…include-errors # Conflicts: # CHANGELOG.md # docs/guide/migration-from-3.x-to-4.0.md
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
Context
FILTERtreated text and errors in its conditions (theincludeargument) asFALSEand dropped those rows without a sign. Microsoft Excel returns#VALUE!for text and returns an error as is. With1,2inA1:A2andTRUE,"x"inB1:B2,=FILTER(A1:A2, B1:B2)returned1where Excel returns#VALUE!.The condition loop in
ArrayPlugin.filter()now:#VALUE!for any text, before boolean coercion.coerceScalarToBooleanreads"TRUE","FALSE"and""as booleans, but Excel rejects them in a condition.These checks apply to
includeonly. Excel's third argument isif_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 notTRUE. Blank cells,FALSEand0still drop a row, and other numbers keep it, as before.Breaking change. Rows that
FILTERused 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 inmigration-from-3.x-to-4.0.mdlists the cases and the fix: returnFALSE()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 jestinhyperformula/with the pairedhyperformula-testsbranchfix/hf-591-filter-include-errors(handsontable/hyperformula-tests#120), after merging the currentdevelop: 539 suites, 8,377 tests passed, 3 skipped.FILTERcases: 9 fail ondevelopand 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:buildpasses, including the new migration guide.npm run verify:typings, andeslinton 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,3inA1:A3and the conditions inB1:B3. Google Sheets drops a row with text or an error ininclude, as HyperFormula 3.x did:=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/A3#N/A=FILTER(A1:A3, B1:B3),B1:B3=="TRUE",="1"or=""first#VALUE!1,2,3for="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!#DIV/0!=FILTER(A1:A3, B1:B3),B1:B3= blank,2,0222=FILTER(A1:A3, B1:B3),B1:B3=TRUE,-1,0.51,2,31,2,31,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,TRUE222Public API changes
None.
FILTERreturns#VALUE!or an error where it used to drop rows (see Context).Out of scope and follow-ups
None.
Types of changes
Related issues
Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code
Note
Low Risk
Scoped to
FILTERcondition handling inArrayPlugin; 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 viacoerceScalarToBoolean, so strings like"TRUE"are rejected too), andCellErrorvalues from a condition are returned as-is instead of being treated asFALSE.The changelog records the fix (#1891). Numeric/boolean filtering behavior is unchanged—blank cells,
FALSE, and0still exclude rows.Reviewed by Cursor Bugbot for commit 6c8117d. Configure here.