Mismatched_aggregation. Custom aggregations can't contain both aggregated and nonaggregated fields, in any combination

hi,

I have the below and I get “Mismatched aggregation. Custom aggregations can’t contain both aggregated and nonaggregated fields, in any combination.”

Why? how can I make it work?

max({Amount USD}, [{case_id}]) /
distinct_count(dateDiff(truncDate("WK", truncDate('YYYY', {beta Date})), {beta Date}, 'WK')+1)

yeap. Found it. it needed also a sum().

so this works now

sum(max({Amount USD}, [{case_id}])) /
distinct_count(dateDiff(truncDate(“WK”, truncDate(‘YYYY’, {beta Date})), {beta Date}, ‘WK’)+1)