Repository navigation
SUBTOTAL 109-111 leave out nested subtotals like 1-11 (#556) - #607
Merged
Merged
Conversation
MarekSpodBiedry
marked this pull request as ready for review
October 12, 2026 06:53
Member
|
Merged — thank you @MarekSpodBiedry for the contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #556.
SUBTOTAL(101..111, ...)counted a nestedSUBTOTAL/AGGREGATEcell in its range as data, soSUBTOTAL(109,A1:A2)with A1=2 and A2==SUBTOTAL(9,A1)gave 4 instead of 2. The cause is incrates/calc/src/eval.rs: SUBTOTAL 101-111 are mapped to AGGREGATE option 5, andskip_nestedwasoptions <= 3, so for 101-111 it was false.Microsoft's SUBTOTAL reference says nested subtotals in the references are always ignored, whatever the function number. The fix makes
skip_nestedtrue for every SUBTOTAL call. AGGREGATE keeps its own rule (it leaves out nested cells only for options 0-3), so its behaviour does not change.Test
subtotal_109_skips_nested_subtotalincrates/calc/src/tests.rs:SUBTOTAL(109,A1:A2),SUBTOTAL(9,A1:A2)andSUBTOTAL(109,A1)all give 2 (the first gave 4 before the fix);SUBTOTAL(109,A1:A3)gives 1 (the hidden row and the nested subtotal are both left out) andSUBTOTAL(9,A1:A3)gives 3.The existing
subtotal_skips_hiddenandsubtotal_skips_filtered_rowstests cover the hidden-row and filter rules, which do not change.