How to Calculate a Weighted Average in Excel With SUMPRODUCT
Find the average price per unit when orders have different quantities. Check the answer against the total cost and spot a misleading simple average.
Follow these steps at your own pace. Check product terms and prices directly with providers before purchasing.
Quick answer
With quantities in A2:A3 and unit prices in B2:B3, enter
=SUMPRODUCT(A2:A3,B2:B3)/SUM(A2:A3). Excel multiplies each quantity by its own price, adds those costs and divides by the total number of units. Two units at $10 and eight at $15 give an average of $14 per unit.
1. Choose what should count equally
Suppose you bought the same packing box twice. The first order contained two boxes at $10 each. The second contained eight at $15 each. To find the average cost of one box, give each box an equal share of the result. The second price should therefore count four times as much as the first.
Type Units in A1 and Unit price in B1. In row 2 enter 2 and 10. In row 3 enter 8 and 15. Enter the price of one box in column B. Using an order total there would multiply the quantity twice.
2. Calculate the total cost first
In D2, type =SUMPRODUCT(A2:A3,B2:B3) and press Enter. The result should be 140. Check it by hand. The first order cost $20 and the second cost $120. In D3 enter =SUM(A2:A3). You should have 10 boxes.
| Units | Unit price | Order cost |
|---|---|---|
| 2 | $10 | $20 |
| 8 | $15 | $120 |
| 10 total | $14 average | $140 total |
3. Divide by the total weight
In D4, enter =D2/D3. You should see 14. To keep the calculation in a single cell, enter =SUMPRODUCT(A2:A3,B2:B3)/SUM(A2:A3) in D5. Format the two results as Currency and compare them. Both should read $14.00.
4. Test whether the weighting makes sense
Change A3 from 8 to 2. Both orders now have the same number of boxes, so the weighted average falls to $12.50. Change A3 back to 8. If your answer stays at $12.50, check whether you used =AVERAGE(B2:B3). That calculation gives each order equal influence regardless of its size.
What to check when you add more rows
Extend both ranges in SUMPRODUCT and the quantity range in SUM to the same final row. A mismatch in array size can cause #VALUE!. If total quantity is zero, there is no average unit cost. Check for missing quantities or returns before using the result.
Microsoft Support · SUMPRODUCT function
Comments
Read or join the discussion.