rusackas opened a new pull request, #42761: URL: https://github.com/apache/superset/pull/42761
### SUMMARY #41463 (SIP-216, merged via #41184) correctly moved Pivot Table totals/subtotals to DB-computed rollup queries, fixing non-additive metrics (ratios, `COUNT_DISTINCT`, `AVG`, etc.) that were previously wrong when re-aggregated client-side. As part of that change, the Pivot Table's old "Aggregation function" control was removed entirely, and its "Sum as Fraction of Total/Rows/Columns" options went with it. That was collateral damage, not something the SIP identified as broken: those fraction variants only ever wrapped `Sum`/`Count` (both additive), so they were mathematically correct even before #41184, and users are now asking for the display mode back (originally raised against #41463). This reintroduces it as a standalone **"Show values as"** control, rather than resurrecting the removed per-metric "Aggregation function" selector. The new architecture actually makes this cleaner than before: every cell already holds a DB-correct rollup value at every scope (its own cell, row total, column total, grand total), so showing a value as a fraction of one of those scopes is now a pure presentational transform at render time. It reuses `react-pivottable`'s existing `fractionOf` template — the same one the old "Sum as Fraction of ..." options used — wrapping the current passthrough `cellValue` aggregator instead of `sum()`/`count()`, and reusing the same row/column/grand-total lookup (`getAggregator`) the removed feature relied on. No new query, no touching `grouping_sets`, no per-metric control to reintroduce. Percentage display always uses a fixed percent format; a per-metric custom formatter (currency, decimals, etc.) doesn't apply to a ratio, so custom column formatters are skipped while a fraction mode is active (matching the old behavior, which also always used a fixed percent formatter regardless of the metric's own format). ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Pivot table of `birth_names` (rows = `state`, columns = `gender`, metric = `sum__num`, row/column totals on), cycling through the new control: **Actual values (default, unchanged behavior):** <img width="800" alt="Actual values, with row and column totals" src="https://github.com/user-attachments/assets/19b4df89-ae9d-48e3-b50f-151359467ced" /> **% of row total** — every row (and the row-total column) sums to 100.0%: <img width="800" alt="Percent of row total" src="https://github.com/user-attachments/assets/5e10784f-7d91-4119-9bdf-5a1e7a8e1d81" /> **% of column total** — every column (and the column-total row) sums to 100.0%: <img width="800" alt="Percent of column total" src="https://github.com/user-attachments/assets/b93207e5-74ba-4fdc-957f-c27ca7c31a2f" /> **% of grand total** — the grand-total corner reads 100.0%, every other cell is its share of it: <img width="800" alt="Percent of grand total" src="https://github.com/user-attachments/assets/539b4675-7f3d-4250-8080-008949e9bdfa" /> **The control itself**, alongside the rest of the Options panel: <img width="400" alt="Show values as control, dropdown open showing all four options" src="https://github.com/user-attachments/assets/9ffe8e17-0595-4209-bbd9-06ddece563df" /> ### TESTING INSTRUCTIONS 1. Create or open a Pivot Table chart with at least one row grouping, one column grouping, and one metric. 2. In the **Options** panel, find the new **Show values as** control (below "Combine metrics") and select "% of row total", "% of column total", or "% of grand total". 3. Confirm cell values re-render as percentages without a new query being issued (it's a `renderTrigger` control). 4. Confirm each row's percentages sum to 100% in "% of row total" mode, each column's percentages sum to 100% in "% of column total" mode, and the grand total cell always reads 100%. 5. Switch back to "Actual values" (the default) and confirm the original numeric display returns. 6. `npx jest --runInBand plugins/plugin-chart-pivot-table` — all 96 tests pass, including 5 new tests covering all three fraction modes plus the default/unset case. 7. `npx tsc --noEmit -p plugins/plugin-chart-pivot-table/tsconfig.json` and `pre-commit run` on the changed files both pass clean. ### ADDITIONAL INFORMATION - [x] Has associated issue: #41463 - [ ] Required feature flags: - [x] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [x] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
