Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Weighted average

Hi all, need some help please in calculating the weighted average, for this contrived example I have 2 figures which are in a Pivot table, in  the following format (one fact table), lets say one figure represents the count of sales and the another figure represents the average time of those sales per department.

How can I calculate the weighted average time of sales of each different product for a company (i.e. not by department)???

Capture.PNG

I've tried something like this but I think I need to use the AGGR function but not quite sure how.

=SUM(({$<Type={"Count of sale"}>}[Shoe Sales]) * ({$<Type={"Average (days)"}>}[Shoe Sales]))/SUM({$<Type={"Count of sale"}>}[Shoe Sales])

Many thanks in advance!

1 Solution

Accepted Solutions
sunny_talwar

May be this:

Sum(Aggr(Only({<Type = {'Count of sale'}>} [Shoe Sales]) * Only({<Type = {'Average (days)'}>}[Shoe Sales]), [File Month], [Supplier Name], Department))/Sum({<Type = {'Count of sale'}>} [Shoe Sales])

View solution in original post

3 Replies
sunny_talwar

May be this:

Sum(Aggr(Only({<Type = {'Count of sale'}>} [Shoe Sales]) * Only({<Type = {'Average (days)'}>}[Shoe Sales]), [File Month], [Supplier Name], Department))/Sum({<Type = {'Count of sale'}>} [Shoe Sales])

Not applicable
Author

Many thanks for this, works perfectly, I was actually trying it with Only instead of Sum but was missing the AGGR bit, thanks again!

sunny_talwar

Awesome