Not sure if I fully understand.
It would be helpful if you could explain your setting with some sample lines of data and expected result.
You may also need to check for expression evaluation per Dimensionality() or SecondaryDimensionality() (for horizontal dimensions) depending on your need to use different aggregations on different aggregation levels, like
=If(Dimensionality() = 0,
Sum( Aggr( Avg(Sales), Category, Product)), // or maybe Sum( Aggr( Avg(Sales), Category)) ?