Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Weighted Average in time spread...

Dear users,

I want to show weighted average on a Line Chart. Dimensions are: YearMonth and Category.

Below example regarding one project, there will be many YearMonth records, but Category will be still 1, 2, 3...

At the moment, my weighted average metric is like below, but it calculates me total by number of months. Is it possible to show me aggregated weighted average for each YearMont dimension? This will allow to show me weighted averages on linear chart, so there will be possibility to track weighted average changes in time.

Thank you in advance.

//Weighted average metric:

sum (

    aggr(

        (sum(volume) / sum(total volume))*

          sum(nettprice), category, YearMonth)    )

      

YearMonthCategoryNettPriceWeighted AvgVolumeDesired goal of showing weithted avg on line chart
Category1 216    1 263,34   
2016-06Category1  216,00      30,86          180,48                   216,00   
2016-07Category1  216,00      30,86          180,48                   216,00   
2016-08Category1  216,00      30,86          180,48                   216,00   
2016-09Category1  216,00      30,86          180,48                   216,00   
2016-10Category1  216,00      30,86          180,48                   216,00   
2016-11Category1  216,00      30,86          180,48                   216,00   
2016-12Category1  216,00      30,86          180,48                   216,00   
Category2 115,2       134,55   
2016-06Category2 115,20         16,46           19,22                   115,20   
2016-07Category2 115,20         16,46           19,22                   115,20   
2016-08Category2 115,20         16,46           19,22                   115,20   
2016-09Category2 115,20         16,46           19,22                   115,20   
2016-10Category2 115,20         16,46           19,22                   115,20   
2016-11Category2 115,20         16,46           19,22                   115,20   
2016-12Category2 115,20         16,46           19,22                   115,20   
11 Replies
sunny_talwar

Try this:

Sum(Sale * NetPrice)/Sum(Sale)


Capture.PNG

Not applicable
Author

Hello Sunny,

thank you, but in the meantime I used expression but with PriceVolume calculation in the script.

In fact, whole process is far more complicated in my application than in my example, but it worked.

Result is the same, so we may close this topic. Thank you.

Best,
K.