diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts b/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts index cfd858a345669..40fa06ba427a1 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts @@ -104,7 +104,7 @@ describe('getSeries', () => { fieldName: 'document', isFullReference: true, params: { - formula: 'clamp(max(day_of_week_i), 0, max(day_of_week_i))', + formula: 'pick_max(max(day_of_week_i), 0)', }, }, ]); diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts b/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts index e3d8fa0434cbd..f6a368382b5b4 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts @@ -220,7 +220,10 @@ export const getSiblingPipelineSeriesFormula = ( // support nested aggs with formula const additionalSubFunction = metrics.find((metric) => metric.id === subMetricField); let formula = `${aggregationMap.name}(`; - let minMax = ''; + let minimumValue = ''; + if (currentMetric.type === 'positive_only') { + minimumValue = `, 0`; + } if (additionalSubFunction) { const additionalPipelineAggMap = SUPPORTED_METRICS[additionalSubFunction.type]; if (!additionalPipelineAggMap) { @@ -228,14 +231,9 @@ export const getSiblingPipelineSeriesFormula = ( } const additionalSubFunctionField = additionalSubFunction.type !== 'count' ? additionalSubFunction.field : ''; - if (currentMetric.type === 'positive_only') { - minMax = `, 0, ${pipelineAggMap.name}(${additionalPipelineAggMap.name}(${ - additionalSubFunctionField ?? '' - }))`; - } formula += `${pipelineAggMap.name}(${additionalPipelineAggMap.name}(${ additionalSubFunctionField ?? '' - }))${minMax})`; + }))${minimumValue})`; } else { let additionalFunctionArgs; // handle percentile and percentile_rank @@ -246,14 +244,9 @@ export const getSiblingPipelineSeriesFormula = ( if (pipelineAggMap.name === 'percentile_rank' && nestedMetaValue) { additionalFunctionArgs = `, value=${nestedMetaValue}`; } - if (currentMetric.type === 'positive_only') { - minMax = `, 0, ${pipelineAggMap.name}(${subMetricField ?? ''}${ - additionalFunctionArgs ? `${additionalFunctionArgs}` : '' - })`; - } formula += `${pipelineAggMap.name}(${subMetricField ?? ''}${ additionalFunctionArgs ? `${additionalFunctionArgs}` : '' - })${minMax})`; + })${minimumValue})`; } return formula; }; diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts b/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts index 30b6f47da5f7e..29bf2008e208d 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts @@ -93,7 +93,7 @@ export const SUPPORTED_METRICS: { [key: string]: AggOptions } = { isFullReference: true, }, positive_only: { - name: 'clamp', + name: 'pick_max', isFullReference: true, }, static: {