KNOWLEDGE BASE

## Calculating Weighted Averages

Product(s): Tableau Desktop
Version(s): 8.1, 8.0, 7.0

Article Note: This article is no longer actively maintained by Tableau. We continue to make it available because the information is still valuable, but some steps may vary due to product changes.

Averages are used to summarize data results. However, the type of average chosen to represent the results can affect the overall conclusions drawn from the data. This article covers how to calculate weighted averages and uses an example that compares the results from using a weighted average versus an unweighted average to summarize the data.

## Raw Data

The data in this example includes survey results for two different survey tests summarized by the four groups who took each test, their respective sample sizes, and their frequency of affirmative answers:

## Calculating the Weighted Average

The weighted average of the results is calculated by factoring in the sample size with the rate of affirmative answers. This helps to create a more even comparison between the two test results. The general formula for calculating a weighted average is as follows:

`SUM (Weight * Value) / SUM (Weight)`

The following steps show how to create a calculated field in Tableau and adjust this formula for the attached workbook.

### Step 1

Select Analysis > Create Calculated Field.

### Step 2

In the Calculated Field dialog box, complete the following steps.

1. For Name, type Weighted Average.
2. In the Formula box, build the weighted averages formula for the attached workbook’s data source:

`SUM([Frequency]*[Sample Size])/SUM([Sample Size])`

3. Confirm that the status message indicates that the formula is valid, and then click OK.

## Compare the Results

The view below shows the comparison in using weighted vs. unweighted average to summarize the results. In this example, it the unweighted average shows that Test 2 has the highest frequency of affirmative responses, but the weighted average shows that Test 1 has the highest frequency of affirmative responses.

Alternate Search Terms:How To Calculations