Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to calculate Sum of Means ?

Help me write some expressions, attached is the sample document

My first chart i.e. "Avg Mean Price Per Product" would be like

Sum(Mean price of all purchases of a customer)/Total Number of Customers

My first chart i.e. "Avg Mean Price Per Product" would be like

Sum(Max price of all purchases of a customer)/Total Number of Customers

***     There can be multiple purchases for a product against single customer. I have updated the document too.

Any help is highly appreciated.

Message was edited by: Mubbasher Khaliq (Multiple purchases for a product against single customer added)

1 Solution

Accepted Solutions
whiteline
Master II
Master II

You should add Customer as dimension to aggr, otherwise you choose to calculate aggr() regardless of customer (aka total<> modifier).

Read the help about aggr() function.

View solution in original post

10 Replies
hic
Former Employee
Former Employee

If you want to average per customer, then sum the averages, you should use

     Sum(Aggr(Avg(Price),Customer))

HIC

whiteline
Master II
Master II

Hi.

aggr() function can help you to calculate the expression for the aggregation level that differs from the chart dimensions.

alexandros17
Partner - Champion III
Partner - Champion III

Here it is

Anonymous
Not applicable
Author

Hi,

Have a look on RangeAvg() function.

er_mohit
Master II
Master II

See the attached file

Not applicable
Author

Thanks, This helped me a lot , but when I write this expression

If within Aggr function I use Sum/Count rather than Avg then the out put of Count is not right. As can be seen below.

Expression:

Sum(Aggr(Count(1),Product))

Output:

Product Count Per Customer.png

Why it is counting every product count against single customer.

Desired Output:

Desired.png

Not applicable
Author

Please check my reply to above post. Thanks.

whiteline
Master II
Master II

You should add Customer as dimension to aggr, otherwise you choose to calculate aggr() regardless of customer (aka total<> modifier).

Read the help about aggr() function.

whiteline
Master II
Master II

Since QV can't choose the customer to show the result it takes the first one.

To make the aggr() working as total modifier you should add 'nodistinct', then QV repeats 25 for each customer.