diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts b/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts index fab802b146ac8..7ded21084b2d8 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/operators/renameOperator.ts @@ -29,7 +29,17 @@ export const renameOperator: PostProcessingFactory = ( queryObject, ) => { const metrics = ensureIsArray(queryObject.metrics); - if (metrics.length === 1) { + const columns = ensureIsArray(queryObject.columns); + const { x_axis: xAxis } = formData; + // remove metric name in the MultiIndex when + // 1) only 1 metric + // 2) exist dimentsion + // 3) exist xAxis + if ( + metrics.length === 1 && + columns.length > 0 && + (xAxis || queryObject.is_timeseries) + ) { const mainQueryMetricName = getMetricLabel(metrics[0]); return { operation: 'rename', diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeCompareRenameOperator.ts b/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeCompareRenameOperator.ts index 2dae01c5fa81c..bbb4e432a1c5a 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeCompareRenameOperator.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/src/operators/timeCompareRenameOperator.ts @@ -28,8 +28,16 @@ import { getMetricOffsetsMap, isValidTimeCompare } from './utils'; export const timeCompareRenameOperator: PostProcessingFactory = (formData, queryObject) => { const metrics = ensureIsArray(queryObject.metrics); + const columns = ensureIsArray(queryObject.columns); + const { x_axis: xAxis } = formData; + // remove metric name in the MultiIndex when + // 1) only 1 metric + // 2) exist dimentsion + // 3) exist xAxis if ( metrics.length === 1 && + columns.length > 0 && + (xAxis || queryObject.is_timeseries) && // "actual values" will add derived metric. isValidTimeCompare(formData, queryObject) && formData.comparison_type === ComparisionType.Values