[FIX] pivot: unused pivot detection #8539
Open
hokolomopo wants to merge 2 commits into
Open
Conversation
If a pivot has a calculated measure that refers to a second pivot, the second pivot is not detected as used. This commit fixes that. Note: the fix does not fix 100% of the issues. A pivot only referenced in other places (eg. in a CF rule formula) will still not be detected as used. But checking every other place the pivot can be referenced is expensive and error-prone. That may be done in master. Task: 6105894
If a formula has two pivots (eg. `=PIVOT(1) + PIVOT(2)`), the second pivot will not be detected as used. Task: 6105894
Collaborator
| }); | ||
| }); | ||
|
|
||
| test("Pivot highlights works with multiple pivot formulas in the same cell", () => { |
Collaborator
There was a problem hiding this comment.
this test is duplicated with the one above
Comment on lines
136
to
140
| const cell = this.getters.getCorrespondingFormulaCell(position); | ||
| if (cell && cell.isFormula) { | ||
| const pivotFunction = this.getFirstPivotFunction( | ||
| position.sheetId, | ||
| cell.compiledFormula.tokens | ||
| ); | ||
| if (pivotFunction) { | ||
| const pivotId = pivotFunction.args[0]?.toString(); | ||
| return pivotId && this.getters.getPivotId(pivotId); | ||
| } | ||
| return this.getPivotIdsFromPosition(position)[0]; | ||
| } | ||
| return undefined; |
Collaborator
There was a problem hiding this comment.
can be simplified to
getPivotIdFromPosition(position: CellPosition): UID | undefined {
return this.getPivotIdsFromPosition(position)[0];
}
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.

Description:
[FIX] pivot: unused pivot detection with composed formula
If a formula has two pivots (eg.
=PIVOT(1) + PIVOT(2)), thesecond pivot will not be detected as used.
[FIX] pivot: unused pivot detection with calculated measure
If a pivot has a calculated measure that refers to a second pivot,
the second pivot is not detected as used. This commit fixes that.
Note: the fix does not fix 100% of the issues. A pivot only referenced
in other places (eg. in a CF rule formula) will still not be
detected as used. But checking every other place the pivot can be
referenced is expensive and error-prone. That may be done in master.
Task: 6105894
review checklist