I don't think you need the aggr function. I think the problem is that you divide the Sum(...) with Divisor, which is an unaggregated number. This causes problems in all cases where there is more than one possible value of Divisor. You should either move the division into the Sum(...) or you should divide with Avg(Divisor).