Mismatched aggregation expression

I want to use this expression-

ifelse(
{Growing stage} = 1,
sum (min({Current growing plants}, [farm,{batch id}])),
0
)

And I get this error-
Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination.

How can I solve it?

Thanks in advance.

Hi @miap,

Can you try this?
sum(min(ifelse({Growing stage} = 1, {Current growing plants}, 0), [farm,{batch id}]))

Amazing thank u so much!