Skip to main contentSign InHelp

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Documents for QlikView related information.

- Qlik Community
- :
- Qlik Data Analytics Forums
- :
- QlikView
- :
- QlikView Documents
- :
- What’s a Weighted Average and how do you calculate...

Options

- Article History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Email to a Friend
- Printer Friendly Page
- Report Inappropriate Content

harvinderjohal

Creator

2014-02-24
06:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

What’s a Weighted Average and how do you calculate it in QlikView?

Citing Investopedia, the definition of a ‘Weighted Average’ is “An average in which each quantity to be averaged is assigned a weight. These weightings determine the relative importance of each quantity on the average. Weightings are the equivalent of having that many like items with the same value involved in the average.”

Weighted Average. In *Formula, Financial Theory*. Retrieved February 12^{th}, 2014, from http://www.investopedia.com/terms/w/weightedaverage.asp.

I created the below example in Excel to describe the concept:

Assume you have the following data where you have 5 people, 3 of them are 25 years old and 2 are 28 years old. You then have weightings assigned to the various values:

Step 1 - You would the multiple each value by its weight. To do this in the example, first multiply each value (Age) by it’s weight (Age * Weight):

Step 2 – Get the total value of all the numbers calculated in Step1.

Step 3 – Add up the total weighting values

Step 4 – Divide the total value of Step 2 by the total weight of Step 3:

This number now represents the weighted average.

To perform this same operation in QlikView, you would create a Chart – a Straight Table.

The Dimension would be on the Age

You would then create 2 Expressions – 1 Expression to calculate the Weighted Total over Age and a final Expression that would calculate the Weighted Average. You would use the AGGR() function to perform this task – this function will return a valule of an expression calculated over a dimension (ie. Get me the total value of Weight calculated over the Dimension Age)

To create the total for the Weight, you would use the following syntax:

**Weighted Total**

Sum(Aggr(Sum(Total Weight), Age))

To create the **Weighted Average**, you would use the following calculation:

Sum(Total Age * Aggr(Sum(Weight), Age)) / Sum(Total Aggr(Sum(Weight), Age))

Comments

vireshkolagimat

Creator III

2016-10-28
05:30 AM

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Email to a Friend
- Report Inappropriate Content

Why you have used the Total key word while calculating the sum of Weight.

In which case we use Total key word and also what is the difference between sum(Weight) and sum(Total Weight).

thank you.

harvinderjohal

Creator

2016-10-28
11:08 AM

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Email to a Friend
- Report Inappropriate Content

vlastimilkosik

Contributor III

2017-04-07
05:51 AM

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hi There,

Are you sure you got this right? I mean the in STEP3. I would say you are supposed to divide it by the actual number of occurrences (number of rows) and not by the weight. You have already took the weight into consideration already by calculating new values. Those new values should be simply averaged now.

Version history

Revision #:

1 of 1

Last update:

2014-02-24
06:57 PM

Updated by: