Repository navigation
Conversation
…ells The shared reducer returned the first error it met before choosing the function, so SUBTOTAL and AGGREGATE 2, 3, 102 and 103 gave #N/A for a range holding one. Excel's COUNT passes over the error and COUNTA counts it, as COUNT and COUNTA themselves do; the other functions still return it. Fixes storytold#4271.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…ells Upstream PR: storytold#4348 Head: c742b7d
Merges the zcode-pr-transfer branch (61 commits transferring open, not-yet-merged upstream PRs into our fork) into main. Docs (docs/ui-parity.md, docs/file-format-parity.md) resolved in favor of main's current changelog state; code from all transferred PRs carried over cleanly. Commits carried over (21 from this session + 40 earlier transfers): storytold#4408, storytold#4405, storytold#4406, storytold#4386, storytold#4379, storytold#4378, storytold#4376, storytold#4375, storytold#4373, storytold#4370, storytold#4369, storytold#4348, storytold#4347, storytold#4345, storytold#4344, storytold#4343, storytold#4341, storytold#4340, storytold#4337, storytold#4336, storytold#4318, storytold#4316, storytold#4315, storytold#4312, storytold#4310, storytold#4307, storytold#4306, storytold#4305, storytold#4303, storytold#4298, storytold#4295, storytold#4287, storytold#4286, storytold#4257, storytold#4256, storytold#4254, storytold#4252, storytold#4251, storytold#4248, storytold#4244, storytold#4243, storytold#4229, storytold#4228, storytold#4227, storytold#4225, storytold#4221, storytold#4220, storytold#4219, storytold#4217, storytold#4424, storytold#4423, storytold#4420, storytold#4419, storytold#4418, storytold#4414, storytold#3617, storytold#2642, storytold#2556, storytold#2321
Fixes #4271
What was wrong
aggregate_implincrates/functions/src/stat/descriptive.rsis the reducer behind SUBTOTAL and AGGREGATE codes 1–13. It returned the first error it met in the cells before looking at which function was asked for. So SUBTOTAL/AGGREGATE 2 (COUNT) and 3 (COUNTA), and SUBTOTAL 102/103, returned#N/Afor a range holding one. Native Excel's COUNT forms pass over the error and its COUNTA forms count it as a nonempty cell, just asCOUNTandCOUNTAdo, as the issue shows.What changed
For codes 2 and 3 (and so 102 and 103), an error in the cells no longer stops the reduction:
Every other code returns the error as before. Option 6 (ignore errors) works as before.
QA report
Main vs branch, end to end (
gridcraft-cli run, real cells)The cells are built with
cell.set, printed, saved to.xlsx, and reopened withgridcraft-cli cat.mainis agridcraft-clibuilt fromorigin/main(19f07f3a); the branch is this PR (c742b7d6). The Excel column is the issue's native Excel 16.0 result; I didn't run Excel myself.Setup:
A1:A2= 10,=NA();B1:B2= 10,=1/0;C1:C4= 10,x,=NA(), blank.=SUBTOTAL(2,A1:A2)=SUBTOTAL(3,A1:A2)=AGGREGATE(2,0,A1:A2)=AGGREGATE(3,0,A1:A2)=COUNT(A1:A2)=COUNTA(A1:A2)=SUBTOTAL(102,B1:B2)(#DIV/0!)=1/0and with codes 102 and 103")=SUBTOTAL(103,B1:B2)=SUBTOTAL(2,B1:B2)=SUBTOTAL(9,A1:A2)(SUM)=AGGREGATE(9,0,A1:A2)=AGGREGATE(2,6,A1:A2)(errors ignored)=AGGREGATE(3,6,A1:A2)=SUBTOTAL(2,C1:C4)(number, text, error, blank)=SUBTOTAL(3,C1:C4)=SUBTOTAL(1,A1:A2)(AVERAGE)Both builds reopened their
.xlsxwith the same 16 values.gridcraft-cli checkon the branch's file: 19 formula cells, 19 matched, round trip 0 of 1 files differ.Through
gridcraft-cli evalwith a literal array, the same reducer gives:=AGGREGATE(2,4,{10,#N/A})=AGGREGATE(3,4,{10,#N/A})=SUBTOTAL(9,{10,#N/A})Test
stat::tests::subtotal_counts_pass_over_or_count_errorscovers:#N/Aand with#DIV/0!;Negative control
With the error returned for every code again (on top of
c742b7d6, then restored withgit checkout), the test fails at its first assertion (SUBTOTAL 2over 10 and#N/A).Gate (macOS arm64)
cargo fmt --all -- --checkcargo clippy -p gridcraft-functions -p gridcraft-calc -p gridcraft-engine --all-targets -- -D warningscargo test -p gridcraft-functions -p gridcraft-calc -p gridcraft-engineNot covered
SUBTOTAL(2,{10,#N/A})now gives 1 too, because it reaches the same reducer. The issue measured references. Excel's SUBTOTAL itself only takes references.cargo xtask ci: I didn't run the fullcargo xtask ci(wasm, layers, the other crates).Summary by CodeRabbit