From 9c4bee7d498f7a7784373a9123b6dbf0a01f2ba0 Mon Sep 17 00:00:00 2001 From: tobiadefami Date: Wed, 12 Aug 2026 21:36:15 +0100 Subject: [PATCH 1/2] fix: preserve zero results from AVERAGEIF --- CHANGELOG.md | 4 ++++ src/interpreter/plugin/ConditionalAggregationPlugin.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ecffc1c4..15b3b4f74d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Fixed + +- Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. + ## [3.4.0] - 2026-08-10 ### Added diff --git a/src/interpreter/plugin/ConditionalAggregationPlugin.ts b/src/interpreter/plugin/ConditionalAggregationPlugin.ts index f2e74e83cf..34e0fc7db6 100644 --- a/src/interpreter/plugin/ConditionalAggregationPlugin.ts +++ b/src/interpreter/plugin/ConditionalAggregationPlugin.ts @@ -200,7 +200,7 @@ export class ConditionalAggregationPlugin extends FunctionPlugin implements Func if (averageResult instanceof CellError) { return averageResult } else { - return averageResult.averageValue() || new CellError(ErrorType.DIV_BY_ZERO) + return averageResult.averageValue() ?? new CellError(ErrorType.DIV_BY_ZERO) } } From 87754111fabfddae5a4ca419f62248107e610005 Mon Sep 17 00:00:00 2001 From: tobiadefami Date: Thu, 13 Aug 2026 10:56:07 +0100 Subject: [PATCH 2/2] docs: link AVERAGEIF fix in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15b3b4f74d..4ccec0bbd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed -- Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. +- Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. [#1733](https://github.com/handsontable/hyperformula/pull/1733) ## [3.4.0] - 2026-08-10