Friday, October 30, 2009

Adding Weighted Averages to a PivotTable

PivotTables are used to boil down huge data sets into something you can more easily understand. They are very good simple aggregations, such as sums, counts, and averages. They can't do weighted averages, however. That doesn't mean you are out of luck; you can still calculate weighted averages using the ideas in this tip.

A good example of how to use calculated fields is for summarizing data differently than you can normally summarize it with a PivotTable. When you create a PivotTable, you can use several different functions to summarize the data that is displayed. For instance, you can create an average of data in a particular field. What if you want to create a weighted average? Excel doesn't provide a function that automatically allows you to do this.

When you have special needs for summations—like weighted averages—the easiest way to achieve your goal is to add an additional column in the source data as an intermediate calculation, and then add a calculated field to the actual PivotTable.

For example, you could add a "WeightedValue" column to your source data. The formula in the column should multiply the weight times the value to be weighted. This means that if your weight is in column C and your value to be weighted is in column D, your formula in the WeightedValue column would simply be like =C2*D2. This formula will be copied down the entire column for all the rows of the data.

You are now ready to create your PivotTable, which you should do as normal with one exception: you need to create a Calculated Field. Follow these steps:

1. Select any of the cells in the PivotTable.

2. Make sure the Options tab of the Ribbon is displayed.

3. In the Tools group, click the Formulas tool and then choose Calculated Field. Excel displays the Insert Calculated Field dialog box, shown earlier in Figure 20.

4. In the Name box, enter a name for your new field.

5. In the Formula box, enter the formula you want used for your weighted average, such as =WeightedValue/Weight. (You use field names in the formula; you can select them from the field list at the bottom of the Insert Calculated Field dialog box.)

6. Click OK.

Your calculated field is now inserted, and you can use the regular summation functions to display a sum of the calculated field; this is your weighted average.

Since there are many different ways that weighted averages can be calculated, it should go without saying that you can modify the formulas and steps presented here to reflect exactly what you need done with your data.

Have questions on this or any other Excel topic? Let us know! We hope this helps you become more efficient!

Posted courtesy of Tips.Net

0 comments:

Post a Comment