Nesting of aggregate functions is not allowed

I need to apply the following formula in case job_id=${Job1}:

2 * sqrt({WSL_calculated_job_1} * (1-{WSL_calculated_job_1})/sum({number_workers})) * 100

Im doing it by:
avg(ifelse(job_id=${Job1},(2 * sqrt({WSL_calculated_job_1} * (1 - {WSL_calculated_job_1})/sum({number_workers})) * 100), NULL))

where WSL_calculated_job_1 is another calculated field:
avg(ifelse({job_id}=${Job1}, {WSL}, NULL))

Im getting nesting of aggregate functions is not allowed when creating calculated field.
Is there a way I can modify the calculated field to make it work?
Thanks in advance!

try making this an avgOver with a pre_agg

1 Like

Hello @Max,
thanks for looking into my question!
I’ve changed (already includes WSL calculation)

to (changed sum to sumOver too since I got nesting error for it roo)
avg(2 * sqrt(avgOver({WSL},[{job_id}], PRE_AGG) * (1-avgOver({WSL},[{job_id}], PRE_AGG))/sumOver({number_workers}, [{job_id}], PRE_AGG))*100,[{job_id}])

how can I visualize it for specific {job_id} = ${Job1}? It does not allow me to add ifelse. Im drawing a line chart

@olgetta Can you just filter using a parameter on your visual?

1 Like