"Mismatched aggregation. Custom aggregations can't contain both aggregated and nonaggregated fields, in any combination" Error for calculated field

I am trying to create a calculation as below where the calculation of metric changes based on the metric name


ifelse( {metric_name} = 'abcd', {Percentage Metrics}, {DPMO Metrics})

where

Percentage Metrics = sum(numerator)*100/sum(denominator)


DPMO Metrics = sum(numerator)*1000000/sum(denominator)

Both numerator and denominator fields are integers. I am a bit confused as to why I am getting this error.

Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination

Both Percentage and DPMO metrics are aggregated fields.

Hi @Chirag_Karkera,

Both Percentage Metrics and DPMO Metrics are aggregated but metric_name isn’t. Everything in your calculated field has to be either aggregated or nonaggregated. You can’t have a mix of both.

Can you try to do it this way instead?

sum(ifelse({metric_name} = 'abcd', {numerator}*100, {numerator}*1000000))/sum(denominator)