How-to recipes · Analysis

How to calculate a weighted average in Excel

Calculate an average where some values count more than others, such as grades or purchase prices, with SUMPRODUCT divided by SUM.

Beginner SUMPRODUCT SUM AVERAGE ROUND

A normal average treats every value equally. Often that is wrong. If you bought 650 units at 3.95 and only 150 at 4.80, the average price you paid is much closer to 3.95 than to 4.80. A final exam worth 30% of the grade should count more than a project worth 10%. A weighted average multiplies each value by its weight, adds the results, and divides by the total weight. In Excel this is a short formula built from SUMPRODUCT and SUM, and it works identically in every version.

The example data

Four purchases of the same material in A1:C5: the quantity bought and the unit price of each batch.

The formula

C7fx=SUMPRODUCT(B2:B5,C2:C5)/SUM(B2:B5)
ABC
1BatchQtyUnit price
2Batch 12004.5
3Batch 25004.2
4Batch 31504.8
5Batch 46503.95
6
74.19

Formatted with two decimals. The exact value is 4.191667.

Result: 4.19

  1. SUMPRODUCT(B2:B5,C2:C5) multiplies each quantity by its price and adds the products: 200×4.50 + 500×4.20 + 150×4.80 + 650×3.95 = 6,287.50, the total amount spent.
  2. SUM(B2:B5) is the total weight, here 1,500 units.
  3. Dividing gives the average price per unit actually paid: 4.19.

Compare that with =AVERAGE(C2:C5), which returns 4.36 (exactly 4.3625). AVERAGE ignores how much was bought at each price, so it overstates the cost because the small expensive batch counts as much as the large cheap one.

Weights that are percentages

For grades, the weights are usually percentages that add up to 100%:

C8fx=SUMPRODUCT(B2:B6,C2:C6)/SUM(C2:C6)
ABC
1ComponentScoreWeight
2Homework8520%
3Quizzes7815%
4Midterm7225%
5Project9010%
6Final exam8130%
7
880.0

The weights in column C are percentages (20% is stored as 0.2) and add up to 100%.

Result: 80.0

Because the weights add up to 1, dividing by SUM(C2:C6) does not change the result here (80.0). Keep the division anyway: if a component is missing or the weights are entered as 20, 15, 25 instead of percentages, the formula still returns the correct average. Without it, whole-number weights would give a "grade" of 8000.

Microsoft 365 alternative

Dynamic arrays let you multiply ranges directly: =SUM(B2:B5*C2:C5)/SUM(B2:B5). It returns the same 4.19. In Excel 2016 and 2019 this needs Ctrl+Shift+Enter, which is why SUMPRODUCT remains the standard formula: it works everywhere without special keys.

Weighted average with a condition

To calculate the weighted average price only for one supplier, multiply a condition into both parts. With suppliers in column D:

Formula
=SUMPRODUCT((D2:D5="Acme")*B2:B5*C2:C5)/SUMIF(D2:D5,"Acme",B2:B5)

The condition is 1 for Acme rows and 0 for others, so only Acme's quantities and prices are multiplied, and SUMIF divides by Acme's total quantity only.

Where weighted averages are used

  • Average cost of stock bought at different prices (as above), and the average exchange rate of several currency purchases.
  • Grades with components of different importance.
  • Average salary or price per region when the regions have different numbers of employees or units: average the regional averages weighted by their counts, never as a plain average.
  • Portfolio return, weighting each investment's return by its value.

Pitfalls

  • Ranges of different sizes. SUMPRODUCT needs arrays of equal size; SUMPRODUCT(B2:B5,C2:C6) returns #VALUE!.
  • Text in the ranges. SUMPRODUCT treats text as 0, so a quantity typed as 200 pcs silently drops out. Keep numbers and units in separate columns.
  • Empty weights. A blank weight counts as 0 and that row is ignored, which may be what you want, or may hide missing data.
  • Averaging averages. If each row is already an average (for example the average order value of a shop), you must weight it by the number of orders, not by revenue.

A quick sanity check: a weighted average always lies between the smallest and the largest value, and it moves towards the values with the biggest weights. If your result falls outside that range, a weight or a range reference is wrong.

Tip. If you need a normal average that skips zeros or blanks, see How to average ignoring zeros in Excel. SUMPRODUCT itself is explained on the SUMPRODUCT function page, and practical finance calculations in Excel for finance basics: loan schedules with PMT, IPMT, PPMT and a budget.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB

More how-to recipes