
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Weighted average calculation
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
- Tags:
- weighted average
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This with expression helped, thank you very much, I wasn't thinking in that direction.
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I guess something like this
Sum(Aggr(Sum({<measure={'Price}>} Value)*Sum({<measure={'Quantity'}>} Value), Item))/Sum({<measure={'Quantity'}>} Value)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is wonderful!!!! thankssssssssss!!!!!!!!!!!!!
