Skip to content

Add RANK.AVG function (HF-420) - #1787

Open
marcin-kordas-hoc wants to merge 3 commits into
developfrom
feat/hf-420-rank-avg
Open

marcin-kordas-hoc wants to merge 3 commits into
developfrom
feat/hf-420-rank-avg

Conversation

@marcin-kordas-hoc

@marcin-kordas-hoc marcin-kordas-hoc commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the RANK.AVG function (HF-420).

  • RANK.AVG(number, ref, [order]) returns the rank of number within ref. Tied values get the average of the ranks they span. order omitted or 0 ranks descending, any other value ascending.
  • Only numeric cells of ref count, including typed numbers (percentages, dates, currency). Text, booleans, empty cells and numeric strings are ignored.
  • Returns #N/A when number is not found, #VALUE! when it cannot be coerced to a number, and propagates an error found in ref.
  • Implemented in MedianPlugin, with a metadata catalogue entry, translations for all built-in languages (English names kept, as no localized name was confirmed), and a CHANGELOG entry.

Behaviour check against Excel

21 formulas were evaluated in Excel Online (MS Graph live session) and in HyperFormula; all 21 results are identical; numbers are compared exactly, as Excel does for ranking (with A1 = 0.1+0.2 and B1 = 0.3, RANK.AVG(0.3, A1:C1) is 3 in both, measured, and covered by a test). They cover ties (including three-way ties, both orders), booleans/text/numeric strings in ref, percentage, date and currency cells, errors in ref, 2D and single-cell ranges, an absent number and a text number.

Tests

Paired tests branch: feat/hf-420-rank-avg in the tests repository (49 tests). Full local run on this head: 503 suites, 6282 passed, 3 skipped.

🤖 Generated with Claude Code


Note

Low Risk
Additive statistical function following existing plugin/metadata/i18n patterns; no changes to core engine or security-sensitive paths.

Overview
Adds Excel-compatible RANK.AVG(number, ref, [order]), which returns a value’s rank in a range and uses the average rank for ties. Optional order defaults to descending (0 or omitted); any other value ranks ascending.

The evaluator lives in MedianPlugin (rankAvg): numeric cells from ref are collected via manyToExactNumbers, #N/A when the number isn’t in the range, and rank is ranksBefore + (ties + 1) / 2. Wiring includes statistical function metadata, RANK.AVG in proprietary license capabilities, a CHANGELOG entry, and the name RANK.AVG in all built-in language packs (no localized aliases yet).

Reviewed by Cursor Bugbot for commit 905872a. Bugbot is set up for automated code reviews on this repo. Configure here.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 5, 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 905872a Commit Preview URL

Branch Preview URL
Oct 08 2026, 04:10 AM

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Performance comparison of head (905872a) vs base (3a9c34b)

                                     testName |    base |    head | change
--------------------------------------------------------------------------
                                      Sheet A |  479.99 |  479.71 | -0.06%
                                      Sheet B |  158.14 |  157.11 | -0.65%
                                      Sheet T |  141.25 |  141.98 | +0.52%
                                Column ranges |  551.52 |  552.39 | +0.16%
                                Sorted lookup | 18012.8 | 19091.3 | +5.99%
Sheet A:  change value, add/remove row/column |   16.31 |    16.3 | -0.06%
 Sheet B: change value, add/remove row/column |  144.37 |  141.94 | -1.68%
                   Column ranges - add column |  169.62 |  168.94 | -0.40%
                Column ranges - without batch |  529.78 |  521.69 | -1.53%
                        Column ranges - batch |  129.44 |  129.02 | -0.32%

marcin-kordas-hoc and others added 3 commits October 8, 2026 03:53
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…og placement

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

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.26%. Comparing base (3a9c34b) to head (905872a).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1787   +/-   ##
========================================
  Coverage    97.26%   97.26%           
========================================
  Files          203      203           
  Lines        16022    16033   +11     
  Branches      3555     3558    +3     
========================================
+ Hits         15583    15594   +11     
  Misses         431      431           
  Partials         8        8           
Files with missing lines Coverage Δ
src/i18n/languages/csCZ.ts 100.00% <ø> (ø)
src/i18n/languages/daDK.ts 100.00% <ø> (ø)
src/i18n/languages/deDE.ts 100.00% <ø> (ø)
src/i18n/languages/enGB.ts 100.00% <ø> (ø)
src/i18n/languages/esES.ts 100.00% <ø> (ø)
src/i18n/languages/fiFI.ts 100.00% <ø> (ø)
src/i18n/languages/frFR.ts 100.00% <ø> (ø)
src/i18n/languages/huHU.ts 100.00% <ø> (ø)
src/i18n/languages/idID.ts 100.00% <ø> (ø)
src/i18n/languages/itIT.ts 100.00% <ø> (ø)
... and 10 more
🚀 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.

This branch has not been deployed

No deployments
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.

1 participant