Smart Statistics · Excel practical tutorial
Excel Weighted Average Tutorial: Calculate the Price You Actually Paid
A small emergency order can cost more per unit than a large planned purchase. If you average the two prices equally, the small order gets as much influence as the large one. The resulting figure describes the average order-line price, not the average price paid for each unit.
This tutorial builds a quantity-weighted purchase price in Excel, with a visible input check and an independent line-value calculation. The worked example uses one comparable packaging item, one currency and a consistent price basis.
Illustrative example · Packaging purchase review
Give every purchased unit the same influence
Source: purchase lines → input checks → price × quantity → total value ÷ total units. The unweighted mean is £10.67; it answers a different question.
Agree the unit before opening the workbook
Use this method when the business question is “What was the average purchase price per unit for this item?” Agree whether a unit means one item, one pack or a kilogram. Convert unlike pack sizes before combining them. Keep currencies and the treatment of discounts, delivery charges and tax consistent.
For this exercise, UnitPrice is the agreed price per individual item, excluding delivery and tax; Units is the positive quantity purchased. It is an operational price calculation, not an inventory valuation method or a supplier ranking model. A change in order mix can move the average without any supplier changing its price.
Create a small purchase table
On a blank sheet named Purchases, enter the following data in A1:C4. All values are an Illustrative example. Enter prices as numbers, then apply currency formatting; do not type currency symbols as text.
| OrderLine | UnitPrice | Units |
|---|---|---|
| A | 10 | 100 |
| B | 14 | 20 |
| C | 8 | 200 |
Select A1:C4, press Ctrl+T, confirm that the table has headers, then use Table Design → Table Name to name it tblPurchases. Add InputCheck in D1 and LineValue in E1.
Excel Tables provide named column references that adjust as rows are added or removed. A formula entered in an empty table column can fill the calculated column. Confirm that all rows receive it. [1]
Make bad inputs visible before calculating
Enter this complete formula in D2, the first InputCheck cell. It requires a nonblank unique OrderLine, a numeric non-negative price and a numeric positive quantity. A zero price is allowed only because a genuine free-of-charge item may be valid; the owner should review that policy.
=IFERROR(IF(AND([@OrderLine]<>"",COUNTIF(tblPurchases[OrderLine],[@OrderLine])=1,ISNUMBER([@UnitPrice]),[@UnitPrice]>=0,ISNUMBER([@Units]),[@Units]>0),"OK","Review"),"Review")
Enter the following in E2, the first LineValue cell. The deliberate #N/A prevents an invalid line being quietly counted as a zero-value purchase.
=IF([@InputCheck]="OK",[@UnitPrice]*[@Units],NA())
The expected LineValue results are £1,000, £280 and £1,600. Every InputCheck must say OK. Keep those calculated columns intact when new data is pasted into the input columns.
Calculate and independently reconcile the answer
Create a Summary sheet. Put the label “Weighted unit price — all rows” in A2 and enter this complete formula in B2:
=IF(COUNTIF(tblPurchases[InputCheck],"OK")<>ROWS(tblPurchases[InputCheck]),NA(),IF(SUM(tblPurchases[Units])=0,NA(),SUMPRODUCT(tblPurchases[UnitPrice],tblPurchases[Units])/SUM(tblPurchases[Units])))
SUMPRODUCT multiplies each price by its matching quantity and adds the products. Dividing by total quantity gives the unit-weighted average. Microsoft documents this approach for weighted averages. [2]
In A3 enter “Line-value cross-check”, and in B3 enter:
=SUM(tblPurchases[LineValue])/SUM(tblPurchases[Units])
Both results must be £9.00: (10 × 100 + 14 × 20 + 8 × 200) ÷ (100 + 20 + 200) = 2,880 ÷ 320. Format B2:B3 as currency with two decimals; retain full precision in the formulas.
For comparison only, label A4 “Unweighted order-line mean” and enter this in B4:
=AVERAGE(tblPurchases[UnitPrice])
This returns approximately £10.67. It gives each purchase line one vote, regardless of quantity. Do not present the difference as a saving: it is a difference between two definitions.
Test the workbook by trying to break it
Missing or text values
Temporarily clear a price, then try a quantity stored as text. InputCheck must show Review and the headline must return #N/A. Restore the original values after each test.
Duplicate and zero rows
Duplicate OrderLine A or set a quantity to zero. Both cases must block the result. Resolve duplicates against source records; do not simply rename them to pass the check.
Equal weights
In a test copy, set every quantity to 100. The weighted and unweighted averages should both be £10.67 when displayed to two decimals. Restore the sample quantities afterwards.
Add a new valid line and confirm the formulas extend and both calculations agree. Then filter out a purchase: the headline should remain unchanged. These SUMPRODUCT and SUM formulas calculate all table rows, including hidden rows; the label must say so.
Avoid a plausible but incomplete answer
Microsoft notes that SUMPRODUCT requires matching array dimensions and treats non-numeric entries as zeros in its array arguments. That is why numeric validation is part of the calculation, not an optional cosmetic check. Avoid full-column ranges when a bounded table will do. [3]
Do not wrap the headline in IFERROR with a zero fallback. “Cannot calculate” is different from “the unit price is zero”. The checked formula deliberately withholds a result until the inputs meet its rules.
Do not mix returns into this model by entering negative quantities: the input check rejects them. Decide whether the required measure is gross purchase price, net acquisition cost or something else, then design and test a returns-aware calculation separately.
The checks cannot prove that the source is complete or that two differently named rows are not duplicates. Reconcile the imported line count, quantities and value to an agreed source extract before circulation.
Make the calculation dependable each month
The purchasing owner approves the item scope, unit conversion and cost basis. The workbook owner maintains formulas and tests. A reviewer reconciles the source totals and records the period, source location and review date.
Keep one controlled workbook location in your Microsoft 365 working environment. Distinguish input columns from calculated columns, retain a reviewed version and show colleagues how to resolve Review rows. A two-minute explanation of the denominator is more useful than an unexplained green KPI.
Track invalid lines found before issue, reconciliation differences and time spent correcting the monthly report. If the model expands to many products, currencies or automated imports, move towards a governed data preparation and reporting process. Never average the product-level averages again: retain their numerators and denominators and combine only comparable populations.
Is your weighted average ready to share?
This checklist assesses evidence; it sends no data and does not save responses.
Frequently asked questions
When is a simple average appropriate?
Use it when each observation should have equal influence. For the average price paid per unit across purchases of different sizes, quantity is the appropriate weight.
Will filtering the table change this weighted average?
No. The SUMPRODUCT and SUM formulas shown include all table rows, including rows hidden by a filter. Label the result as an all-row total.
Why does the checked formula return #N/A?
It deliberately withholds the result when an input check fails or the denominator is zero. Review the flagged rows instead of replacing the error with a zero price.
Can I include returns or different pack sizes?
Not directly in this tutorial. Its input rule requires positive quantities and comparable units. Convert pack sizes and define a separate returns policy before extending the model.
Make your spreadsheet totals explainable
Smart Statistics can review your Excel calculations, strengthen input controls and help turn recurring spreadsheet work into dependable business reporting.