From c025fa1a937fbd6bed6a670367d4af04b5be0280 Mon Sep 17 00:00:00 2001 From: tobiadefami Date: Thu, 12 Nov 2026 20:27:46 +0100 Subject: [PATCH 1/3] Return #VALUE! for text and the error itself for an error in FILTER's 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 --- CHANGELOG.md | 1 + hyperformula/src/interpreter/plugin/ArrayPlugin.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47b081cc2c..fab895c7d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed functions such as `MATCH`, `INDEX` and `COUNTIF` throwing an uncaught `Unknown array` error when they read a range that exactly matches the area of an array formula returning an error, for example `=MATCH(2, B1:B3, 0)` next to `=SORT(A1:A3)` whose source contains `#DIV/0!`. They now read the range cell by cell. [#1876](https://github.com/handsontable/hyperformula/pull/1876) - Fixed unbounded parser cache growth in long-running instances that process many distinct formulas, including when undo is disabled. [#1635](https://github.com/handsontable/hyperformula/issues/1635) - Fixed array formulas spilling past the `maxRows` and `maxColumns` limits: they now return `#SPILL!` when their result extends beyond the sheet edge. [#1774](https://github.com/handsontable/hyperformula/pull/1774) +- Fixed the `FILTER` function ignoring text and errors in its conditions: text now returns `#VALUE!` and an error is returned as is, as in Microsoft Excel. For example, `=FILTER(A1:A2, B1:B2)` with `TRUE` and `"x"` in `B1:B2` now returns `#VALUE!` instead of `1`. ## [3.5.0] - 2026-10-09 diff --git a/hyperformula/src/interpreter/plugin/ArrayPlugin.ts b/hyperformula/src/interpreter/plugin/ArrayPlugin.ts index 27b47096e0..8d21ada760 100644 --- a/hyperformula/src/interpreter/plugin/ArrayPlugin.ts +++ b/hyperformula/src/interpreter/plugin/ArrayPlugin.ts @@ -131,10 +131,17 @@ export class ArrayPlugin extends FunctionPlugin implements FunctionPluginTypeche for (let j = 0; j < rangeVals.width(); j++) { let ok = true for (const filter of rangeFilters) { - const val = coerceScalarToBoolean(filter.data[i][j]) + const condition = filter.data[i][j] + // Excel rejects text in a condition, even "TRUE", which coerceScalarToBoolean would accept. + if (typeof condition === 'string') { + return new CellError(ErrorType.VALUE, ErrorMessage.WrongType) + } + const val = coerceScalarToBoolean(condition) + if (val instanceof CellError) { + return val + } if (val !== true) { ok = false - break } } if (ok) { From 6c8117de2fa15c4ab1097e498fd117c735bd2487 Mon Sep 17 00:00:00 2001 From: tobiadefami Date: Thu, 12 Nov 2026 20:40:38 +0100 Subject: [PATCH 2/3] Link the FILTER changelog entry to its pull request Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fab895c7d6..c21463df3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed functions such as `MATCH`, `INDEX` and `COUNTIF` throwing an uncaught `Unknown array` error when they read a range that exactly matches the area of an array formula returning an error, for example `=MATCH(2, B1:B3, 0)` next to `=SORT(A1:A3)` whose source contains `#DIV/0!`. They now read the range cell by cell. [#1876](https://github.com/handsontable/hyperformula/pull/1876) - Fixed unbounded parser cache growth in long-running instances that process many distinct formulas, including when undo is disabled. [#1635](https://github.com/handsontable/hyperformula/issues/1635) - Fixed array formulas spilling past the `maxRows` and `maxColumns` limits: they now return `#SPILL!` when their result extends beyond the sheet edge. [#1774](https://github.com/handsontable/hyperformula/pull/1774) -- Fixed the `FILTER` function ignoring text and errors in its conditions: text now returns `#VALUE!` and an error is returned as is, as in Microsoft Excel. For example, `=FILTER(A1:A2, B1:B2)` with `TRUE` and `"x"` in `B1:B2` now returns `#VALUE!` instead of `1`. +- Fixed the `FILTER` function ignoring text and errors in its conditions: text now returns `#VALUE!` and an error is returned as is, as in Microsoft Excel. For example, `=FILTER(A1:A2, B1:B2)` with `TRUE` and `"x"` in `B1:B2` now returns `#VALUE!` instead of `1`. [#1891](https://github.com/handsontable/hyperformula/pull/1891) ## [3.5.0] - 2026-10-09 From 5ec67d2f7840530858c3de2a868a6611a4701cb9 Mon Sep 17 00:00:00 2001 From: tobiadefami Date: Wed, 18 Nov 2026 16:29:50 +0100 Subject: [PATCH 3/3] Check only FILTER's include for text and errors, and list it as breaking 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 --- CHANGELOG.md | 2 +- docs/astro.config.mjs | 1 + docs/guide/migration-from-3.x-to-4.0.md | 26 +++++++++++++++++++ .../src/interpreter/plugin/ArrayPlugin.ts | 13 ++++++---- 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 docs/guide/migration-from-3.x-to-4.0.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 06654585b0..a59bb6a776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Changed - **Breaking change**: Changed the license from GPLv3 to a proprietary license. HyperFormula is no longer available under GPLv3; see [`LICENSE.txt`](LICENSE.txt) for the new terms. Versions 3.x and earlier remain available under GPLv3. [#1885](https://github.com/handsontable/hyperformula/pull/1885) +- **Breaking change**: Changed the `FILTER` function to return `#VALUE!` for text in its `include` argument, including the empty text and `"TRUE"`, and to return an error found there, as in Microsoft Excel. Before, it dropped those rows, or kept them for `"TRUE"`. For example, a condition column of `=IF(B1>0, TRUE(), "")` now makes `FILTER` return `#VALUE!`; return `FALSE()` instead of `""`. See the [migration guide](https://hyperformula.handsontable.com/docs/guide/migration-from-3.x-to-4.0.html). [#1891](https://github.com/handsontable/hyperformula/pull/1891) ### Fixed @@ -38,7 +39,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed unbounded parser cache growth in long-running instances that process many distinct formulas, including when undo is disabled. [#1635](https://github.com/handsontable/hyperformula/issues/1635) - Fixed array formulas spilling past the `maxRows` and `maxColumns` limits: they now return `#SPILL!` when their result extends beyond the sheet edge. [#1774](https://github.com/handsontable/hyperformula/pull/1774) - Fixed the `ADDRESS` function adding the sheet separator (`!`) when the `sheetName` argument is an empty argument slot (e.g. `=ADDRESS(2,3,1,FALSE(),)` now returns `R2C3` instead of `!R2C3`), while an explicit `""` still adds it. [#1641](https://github.com/handsontable/hyperformula/issues/1641) -- Fixed the `FILTER` function ignoring text and errors in its conditions: text now returns `#VALUE!` and an error is returned as is, as in Microsoft Excel. For example, `=FILTER(A1:A2, B1:B2)` with `TRUE` and `"x"` in `B1:B2` now returns `#VALUE!` instead of `1`. [#1891](https://github.com/handsontable/hyperformula/pull/1891) ## [3.5.0] - 2026-10-09 diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 1b76177ea4..42937128d7 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -221,6 +221,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= { label: 'Migrating from 0.6 to 1.0', slug: 'guide/migration-from-0.6-to-1.0' }, { label: 'Migrating from 1.x to 2.0', slug: 'guide/migration-from-1.x-to-2.0' }, { label: 'Migrating from 2.x to 3.0', slug: 'guide/migration-from-2.x-to-3.0' }, + { label: 'Migrating from 3.x to 4.0', slug: 'guide/migration-from-3.x-to-4.0' }, ], }, { diff --git a/docs/guide/migration-from-3.x-to-4.0.md b/docs/guide/migration-from-3.x-to-4.0.md new file mode 100644 index 0000000000..d1140bcac0 --- /dev/null +++ b/docs/guide/migration-from-3.x-to-4.0.md @@ -0,0 +1,26 @@ +--- +title: "Migrating from 3.x to 4.0" +tags: + - migration + - migrate + - upgrade + - breaking changes + - v4.0 + - FILTER +--- + +To upgrade your HyperFormula version from 3.x.x to 4.0.0, follow this guide. + +## The `FILTER` function + +HyperFormula 4.0 reads the `include` argument of `FILTER`, its second argument, as Microsoft Excel does. Text in it returns `#VALUE!`, and an error in it is returned: + +| Value in `include` | 3.x | 4.0 | +|:-------------------|:----|:----| +| `TRUE`, a non-zero number | The row is kept | The row is kept | +| `FALSE`, `0`, a blank cell | The row is dropped | The row is dropped | +| Text, such as `"x"` or the empty text `""` | The row is dropped | `#VALUE!` | +| The text `"TRUE"` | The row is kept | `#VALUE!` | +| An error, such as `#DIV/0!` | The row is dropped | The error | + +If a condition column can hold text, for example `=IF(B1>0, TRUE(), "")`, return `FALSE()` instead of `""`. Conditions after `include`, which HyperFormula accepts in addition to Excel, still drop such rows. diff --git a/hyperformula/src/interpreter/plugin/ArrayPlugin.ts b/hyperformula/src/interpreter/plugin/ArrayPlugin.ts index abc5164036..adafd7ef3e 100644 --- a/hyperformula/src/interpreter/plugin/ArrayPlugin.ts +++ b/hyperformula/src/interpreter/plugin/ArrayPlugin.ts @@ -371,18 +371,21 @@ export class ArrayPlugin extends FunctionPlugin implements FunctionPluginTypeche const row = [] for (let j = 0; j < rangeVals.width(); j++) { let ok = true - for (const filter of rangeFilters) { - const condition = filter.data[i][j] - // Excel rejects text in a condition, even "TRUE", which coerceScalarToBoolean would accept. - if (typeof condition === 'string') { + for (let k = 0; k < rangeFilters.length; k++) { + const condition = rangeFilters[k].data[i][j] + // The first condition is Excel's `include`: text in it, even "TRUE", which coerceScalarToBoolean would + // accept, returns #VALUE!, and an error in it is returned. Further conditions are HyperFormula's own + // extension and keep dropping such rows. + if (k === 0 && typeof condition === 'string') { return new CellError(ErrorType.VALUE, ErrorMessage.WrongType) } const val = coerceScalarToBoolean(condition) - if (val instanceof CellError) { + if (k === 0 && val instanceof CellError) { return val } if (val !== true) { ok = false + break } } if (ok) {