rusackas commented on code in PR #42761:
URL: https://github.com/apache/superset/pull/42761#discussion_r3718426009
##########
superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/controlPanel.tsx:
##########
@@ -243,6 +243,29 @@ const config: ControlPanelConfig = {
},
},
],
+ [
+ {
+ name: 'showValuesAs',
+ config: {
+ type: 'SelectControl',
+ label: t('Show values as'),
+ default: ShowValuesAsEnum.ACTUAL,
+ renderTrigger: true,
Review Comment:
Confirmed, `showValuesAs` was `renderTrigger`, but it changes which rollup
levels get queried for non-additive metrics. Pulled that flag off it so
switching it does a real requery instead of reusing stale data.
##########
superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/utilities.ts:
##########
@@ -207,14 +218,26 @@ export default function buildGroupbyCombinations(
...columns.map((_, i) => columns.slice(0, i + 1)),
];
+ // "% of column total" divides each cell by its column's grand total, which
+ // is computed with all rows collapsed; "% of grand total" needs the same.
+ const needsRowsCollapsed =
+ formData.showValuesAs === ShowValuesAsEnum.PERCENT_OF_COLUMN ||
+ formData.showValuesAs === ShowValuesAsEnum.PERCENT_OF_TOTAL;
+ // "% of row total" divides each cell by its row's grand total, which is
+ // computed with all columns collapsed; "% of grand total" needs the same.
+ const needsColumnsCollapsed =
+ formData.showValuesAs === ShowValuesAsEnum.PERCENT_OF_ROW ||
+ formData.showValuesAs === ShowValuesAsEnum.PERCENT_OF_TOTAL;
+
const rowPrefixNeeded = (prefix: QueryFormColumn[]): boolean => {
if (prefix.length === rows.length) return true; // leaf / full level
- if (prefix.length === 0) return !!formData.colTotals; // bottom Total row
+ if (prefix.length === 0) return !!formData.colTotals ||
needsRowsCollapsed; // bottom Total row
return !!formData.rowSubTotals; // row subtotal
};
const colPrefixNeeded = (prefix: QueryFormColumn[]): boolean => {
if (prefix.length === columns.length) return true; // leaf / full level
- if (prefix.length === 0) return !!formData.rowTotals; // right Total column
+ if (prefix.length === 0)
+ return !!formData.rowTotals || needsColumnsCollapsed; // right Total
column
Review Comment:
Good catch, the combineMetric filter was stripping the forced denominator
level right back out since it lands on the opposite axis from the kept
metrics-layout level. Exempted it from that filter.
--
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]