Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I need a little help calculating weighted average in QlikView.
In database table, with customer orders, i have column for quantity and column for price per unit. I need to calculate weighted average price for customer in expression on bar chart:
(Price * Quantity)/ total Quantity = weighted average price for customer orders
I tried few things, but I couldn't calculate it correctly.
Thanks in advance.
Bojan
May be this in a straight table
Dimension:
CustomerOrder
Expression:
Sum(Price * Quantity)/Sum(Quantity)
or this in a text box object
Sum(Aggr(Sum(Price * Quantity)/Sum(Quantity), CustomerOrder))
May be this in a straight table
Dimension:
CustomerOrder
Expression:
Sum(Price * Quantity)/Sum(Quantity)
or this in a text box object
Sum(Aggr(Sum(Price * Quantity)/Sum(Quantity), CustomerOrder))
This with expression helped, thank you very much, I wasn't thinking in that direction.
Regards
And how would you apply this solution (e.g. Sum(Price * Quantity)/Sum(Quantity)) in a set analysis?
namely where you defined Price as sum( {<measure={'Price}>} Value) and Quantity as sum( {<measure={'Quantity'}>} Value)
I guess something like this
Sum(Aggr(Sum({<measure={'Price}>} Value)*Sum({<measure={'Quantity'}>} Value), Item))/Sum({<measure={'Quantity'}>} Value)
This is wonderful!!!! thankssssssssss!!!!!!!!!!!!!