Skip to content

HF-85: Implement DCOUNT database function#1652

Draft
marcin-kordas-hoc wants to merge 10 commits intodevelopfrom
feature/HF-85-implement-function-dcount
Draft

HF-85: Implement DCOUNT database function#1652
marcin-kordas-hoc wants to merge 10 commits intodevelopfrom
feature/HF-85-implement-function-dcount

Conversation

@marcin-kordas-hoc
Copy link
Copy Markdown
Collaborator

Summary

  • New DatabasePlugin with DCOUNT(database, field, criteria) implementation
  • Counts numeric values in a field of a database range that match specified criteria
  • First database function — shared helpers ready for DSUM, DAVERAGE, DMAX, DMIN, etc.

Changes

  • New: src/interpreter/plugin/DatabasePlugin.ts (208 lines)
  • Modified: src/interpreter/plugin/index.ts (export added)
  • Modified: 16 language files in src/i18n/languages/ (DCOUNT translations)
  • Modified: CHANGELOG.md (unreleased entry)

Implementation Details

  • 3 reusable private helpers: resolveFieldIndex(), buildDatabaseCriteria(), rowMatchesCriteria()
  • Field resolution: string (case-insensitive header match) or 1-based numeric index with Math.trunc()
  • Criteria: OR across rows, AND within each row, using CriterionBuilder.fromCellValue()
  • Counts only isExtendedNumber() values
  • Returns 0 when no records match (not error)

Excel Validation

  • 10/10 PASS in validation workbook (Excel Desktop, PL locale)
  • Verified: field index, boolean criteria, multiple AND criteria, error conditions

Tests

  • 16 test cases in hyperformula-tests (matching branch)
  • Groups: core sanity, edge cases, boolean coercion, multiple criteria, errors, float truncation

Review Notes

  • Reviewed by Claude (Sonnet) + Codex (gpt-5.4) in parallel
  • 2 P1 bugs found by Codex and fixed: RichNumber criteria normalization, empty string handling
  • CHANGELOG entry included
  • Float field index truncation (Math.trunc) added per review

Linked

  • Tests PR: handsontable/hyperformula-tests (manual — private repo)
  • ClickUp: HF-85

marcin-kordas-hoc and others added 2 commits April 9, 2026 17:51
Add idiomatic code examples to React, Angular, Vue, and Svelte
integration pages showing HyperFormula initialization and reading
calculated values. Each guide uses framework-specific patterns
(React hooks, Angular service, Vue ref/markRaw, Svelte reactivity).

Closes HF-122.
Add new DatabasePlugin with DCOUNT(database, field, criteria) that counts
numeric values in a specified field column for rows matching criteria.
Supports field resolution by name (case-insensitive) and 1-based index,
OR logic across criteria rows, AND logic within rows, and comparison
operators in criteria values. Includes translations for all 17 languages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qunabu
Copy link
Copy Markdown

qunabu commented Apr 10, 2026

Task linked: HF-85 Implement function DCOUNT

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 10, 2026

Performance comparison of head (2e2ecec) vs base (357eee3)

                                     testName |   base |   head | change
------------------------------------------------------------------------
                                      Sheet A | 479.87 | 484.72 | +1.01%
                                      Sheet B | 152.79 | 155.37 | +1.69%
                                      Sheet T |  136.8 |  136.9 | +0.07%
                                Column ranges | 466.33 | 467.25 | +0.20%
Sheet A:  change value, add/remove row/column |  14.57 |  14.63 | +0.41%
 Sheet B: change value, add/remove row/column |  123.3 | 128.29 | +4.05%
                   Column ranges - add column |  142.4 | 142.94 | +0.38%
                Column ranges - without batch | 430.06 |  428.2 | -0.43%
                        Column ranges - batch | 110.12 |  110.2 | +0.07%

marcin-kordas-hoc and others added 5 commits April 10, 2026 14:52
Add three new database functions to DatabasePlugin with i18n
translations for all 17 languages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove unnecessary type assertions in DAVERAGE, DMAX, DMIN methods.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New DatabasePlugin with shared helpers for the complete D-function family:
DCOUNT, DSUM, DAVERAGE, DMAX, DMIN, DGET, DPRODUCT, DCOUNTA,
DSTDEV, DSTDEVP, DVAR, DVARP.

169 tests across 12 test suites. All pass.
17 language translations per function.
Excel validation: 152/152 PASS (verified in Excel Desktop).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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