Weighted average purchase price in Excel

Divide total net spend by total quantity, not the average of unit prices. Worked example from invoice lines, with units, credit notes and missing amounts.

See the PDF-to-Excel example

The weighted average purchase price is the total net amount paid for an item divided by the total quantity bought: (10 × $2.00 + 90 × $1.00) ÷ 100 = $1.10 per piece, not the $1.50 simple average of the two prices. It is only valid when every line uses the same item, unit and currency, and when each quantity in the denominator has its net amount in the numerator.

A simple average treats a 10-piece order and a 90-piece order as equally important. Weighting by quantity gives the price you actually paid per piece across all purchases, which is the figure you need to compare vendors, check a price trend or set a budget.

How do you calculate a weighted average purchase price?

All amounts in this synthetic example are in US dollars before sales tax or VAT, for the same item bought from two vendor (supplier) invoices.

Invoice lineQuantity (pieces)Net unit priceLine net amount
Invoice 1, line 310$2.00$20.00
Invoice 2, line 190$1.00$90.00
Total100$110.00
  1. Add the accepted line net amounts: $20.00 + $90.00 = $110.00.
  2. Add the matching quantities: 10 + 90 = 100 pieces.
  3. Divide: $110.00 ÷ 100 = $1.10 per piece.

The simple average, ($2.00 + $1.00) ÷ 2 = $1.50, overstates the cost by $0.40 per piece because most pieces were bought at $1.00. As a quick check, with positive quantities and a single unit the weighted result must lie between the lowest and highest unit price ($1.00 and $2.00).

What is the weighted average formula in Excel?

With quantities in B2:B3 and net unit prices in C2:C3:

=SUMPRODUCT(B2:B3, C2:C3) / SUM(B2:B3)

When you already have the line net amounts in D2:D3, the simpler and safer form is =SUM(D2:D3) / SUM(B2:B3). Use the line net directly if it already includes the line discount: multiplying it by quantity again would count quantity twice. The Peppol line net amount is defined the same way, as the line total without VAT including line-level allowances and charges.

Before trusting a SUMPRODUCT result, check that both ranges cover exactly the same rows and that every quantity and price is a number, not text. Compare the row count with the count of numeric cells in each column (=ROWS(C2:C3) against =COUNT(C2:C3)) and investigate any gap. A price stored as text, or an amount with a decimal comma your spreadsheet did not convert, must not leave its quantity in the denominator without its amount in the numerator: rebuild one group’s total from the line nets to confirm. A missing price is a data exception, not a zero-cost purchase. Finally, convert units of measure before averaging so that every quantity in the SUM counts the same unit.

InvoiceLineLab extracts invoice line items from PDF to Excel or CSV, with item references, quantities, units, prices and line net amounts in separate columns when the invoice prints them, plus the invoice and page of each row. Your SUM and SUMPRODUCT formulas run on rows you can trace back to the PDF.

Why must units match before you average?

A quantity in boxes and a quantity in pieces cannot share a denominator. Every invoiced quantity has a unit (in Peppol, the invoiced quantity carries a mandatory unit code), so read it before you add quantities. Add a third synthetic line to the example: 5 boxes of 12 pieces at $18.00 per box, line net $90.00.

  • Converted: 5 × 12 = 60 pieces. Average = ($110.00 + $90.00) ÷ (100 + 60) = $200.00 ÷ 160 = $1.25 per piece.
  • Not converted: $200.00 ÷ (100 + 5) = $1.9048, a false price that mixes boxes and pieces.

Convert with a documented box-to-piece factor for that item, and keep the original quantity and unit beside the converted one. The same rule applies to currency: average lines in one currency, or convert with a recorded rate and date first. For mixed currencies, keep original and converted amounts apart.

Which costs belong in the average price?

Decide the price basis before selecting rows, and label the result accordingly:

  • Net item price: line net amounts, after line discounts, before tax.
  • Price after all discounts: line nets minus an allocated share of invoice-level discounts.
  • Landed cost: item price plus an allocated share of shipping, freight or duties.

Each answers a different question; do not mix them in one average. Then freeze the period and the date field (invoice date and delivery date select different purchases), group by confirmed item identity, unit and currency, and keep the vendor as a grouping field when the question is a vendor comparison. Record invoice and line keys so a re-imported export does not count the same purchase twice.

How do credit notes change the weighted average?

A credit note (credit memo) changes the average differently depending on its reason. These are two separate scenarios applied to the original 100 pieces and $110.00, not cumulative corrections:

  • Price-only credit of $5.00, no goods returned: value $105.00, quantity 100, average $1.05 per piece.
  • Return of 10 of the 90 pieces bought at $1.00: value $100.00, quantity 90, average $100.00 ÷ 90 = $1.1111, displayed as $1.11.

Do not reduce quantity for a price-only credit, and do not subtract a return twice if the accepted rows already include it. Apply one sign convention for credit note lines, record the reason and the linked invoice, and leave a credit pending when its quantity effect cannot be established. Once returns or credits are included, the minimum-maximum range check no longer applies; review their linked effects instead. A zero or negative net quantity means the average is undefined for that group.

What happens when amounts or quantities are missing?

Every row must enter both sides of the division, or neither:

Record conditionNumerator (net amount)Denominator (quantity)Decision
Confirmed item, unit, quantity and netIncludeIncludeEligible
Quantity known, net missingDo not invent zeroExcludeDisclose the excluded purchase
Net known, quantity missingExcludeLeave unresolvedReport the spend separately
Item identity unresolvedExcludeExcludeFix the reference first

Suppose 5 more pieces arrive with no net amount. Leaving them in the denominator gives $110.00 ÷ 105 = $1.0476, falsely below $1.10. The supported result stays $1.10 for the 100 accepted pieces, with one unresolved purchase of 5 pieces disclosed. A sample confirmed at zero price and a missing price are different states. When a row has no product code at all, do not invent a SKU to place it in a group.

How much precision should you keep?

In another synthetic set, accepted line nets are $3.01 for 3 pieces and $7.04 for 7 pieces. The average is $10.05 ÷ 10 = $1.005 per piece. Rounded half up for display it is $1.01, but $1.01 × 10 = $10.10, not the $10.05 actually spent. Keep the unrounded quotient and the two sums for reconciliation, and round only the displayed figure.

This is purchase-price analysis from invoice lines. It is not an inventory valuation method, whose moving-average rules depend on receipts and issues over time, and it says nothing about whether one vendor is always cheaper.

FAQ

What is the formula for weighted average purchase price?

Total net amount of the accepted purchases divided by their total quantity, in the same unit and currency. In Excel: =SUMPRODUCT(quantities, prices) / SUM(quantities).

Why is the weighted average different from the average of unit prices?

The simple average gives every purchase the same weight. The weighted average gives each price the weight of the quantity bought at that price.

Should I include shipping in the average purchase price?

Only if you are measuring landed cost. Keep it in a separate result labeled as such, next to the net item price.

How do I handle a return in the weighted average?

Reduce both the quantity and the value by the returned amounts, once. A price-only credit reduces the value but not the quantity.

Continue the checks

For a table that keeps invoice header fields apart from item rows, see line items versus header fields in Excel. The synthetic invoice example shows the row structure behind these formulas, and invoice data validation explains the row-by-row checks against the PDF.

Sources and further reading

Get started with InvoiceLineLab

Enter your work email to get access to InvoiceLineLab. No account or payment is created at this stage.

Submitting sends your email and visit context to our publisher’s infrastructure, named on the Privacy page. No account, payment or automatic email is triggered. Privacy.