Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a weighted average in my pivot table?

I would like to know how to add a weighted average in my pivot table. In fact, I need to do the following calculation: SUM(col1 * col2)/SUM(col2).

I tried to do it by using the calculated field option but when I enter my formula, I just have the following result as an output: SUM((col1 * col2)/col2) which is equal to SUM(col1).

like image 391
Leep Avatar asked Jul 09 '13 13:07

Leep


People also ask

Can you do a weighted average in a pivot table?

To calculate the weighted average of a data with a Pivot Table, we can add a column to our source data as an intermediate calculation. This is because Excel doesn't provide a function in the Pivot Table that automatically calculates the weighted average.

How do you add a weighted average?

To find a weighted average, multiply each number by its weight, then add the results. If the weights don't add up to one, find the sum of all the variables multiplied by their weight, then divide by the sum of the weights.


1 Answers

You will need 1 calculated field, and 1 helper column

Helper Column

col3=col1*col2

Calculated field:

CF=Col3/Col1

If you try to do the helper column as a calculated field, it will sum col1 and col2, then multiply them together which results in a meaningless answer

like image 128
SeanC Avatar answered Sep 18 '22 12:09

SeanC