How to Calculate Moving Average Cost: Formula, Example, and Adjustments

To calculate moving average cost, divide the total dollar value of every unit in stock by the total number of units on hand, and redo the calculation each time a new shipment arrives. The result is a single per-unit cost that applies to every unit in your warehouse until the next purchase changes it. The method only works inside a perpetual inventory system, where records update with every transaction, and it is accepted under both GAAP and federal tax law.

The Formula

The calculation has one line:

New Unit Cost = (Existing Inventory Value + Cost of New Purchase) ÷ (Existing Units + New Units)

The numerator is dollars. The denominator is units. Every new purchase feeds both sides, and the quotient becomes the cost you carry on every unit going forward.

A Worked Example

Say you have 200 widgets in stock at $8 each, for a total inventory value of $1,600. A supplier delivers 500 more widgets at $10 each, costing $5,000. The math:

  • Total inventory value: $1,600 + $5,000 = $6,600
  • Total units: 200 + 500 = 700
  • New unit cost: $6,600 ÷ 700 = $9.43 (rounded)

Every widget in the warehouse now carries a $9.43 cost, regardless of which shipment it came from. That figure holds until the next purchase arrives and triggers another recalculation. Sales in the meantime reduce the quantity and total value in proportion, but they do not change the per-unit cost.

What Counts as “Cost”

The cost you plug into the formula is not just the supplier’s invoice price. Federal tax rules require businesses to capitalize direct costs and an allocable share of indirect costs into inventory, including freight, insurance during transit, import duties, and warehouse handling.1Office of the Law Revision Counsel. 26 USC 263A – Capitalization and Inclusion in Inventory Costs of Certain Expenses These landed costs increase your numerator and raise the per-unit average. If you bought 500 units at $10 each but paid $250 in freight, your true purchase cost is $5,250, not $5,000.

Purchase discounts pull the other way. If a supplier offers a 2% discount for paying within 10 days and you take it, the net amount is what enters the formula. Recording the gross invoice price overstates inventory and inflates cost of goods sold down the line. Most accounting systems handle this automatically at payment, though small timing differences sometimes post to a price-variance account rather than adjusting the moving average retroactively.

Recalculate Before Recording Sales

Sequence matters more than most people expect. Recalculate the unit cost before you record any sales from the new batch. If sales are posted first and the recalculation happens second, cost of goods sold uses the old average and remaining inventory value drifts out of line with reality.

Consider a slightly different day. You start with 300 units valued at $9 each ($2,700 total). A delivery brings 150 units at $11 each ($1,650). Before touching any sales orders:

  • Combined value: $2,700 + $1,650 = $4,350
  • Combined units: 300 + 150 = 450
  • Updated unit cost: $4,350 ÷ 450 = $9.67 (rounded)

Every sale that day now uses $9.67 as the cost basis per unit until the next shipment. Sell 100 units and your cost of goods sold is $967, with 350 units left at $9.67 each ($3,384.50). The per-unit cost does not shift when units leave. Only new purchases trigger a recalculation.

Errors compound quickly here. A business that receives multiple shipments a day but batches its entries at night can end up with sales recorded between two unprocessed receipts, skewing every downstream number. Real-time recording is the only reliable way to keep the moving average accurate.

Valuing Sales and Remaining Inventory

When a customer buys, multiply the current moving average cost by the units sold to get cost of goods sold. That amount hits the income statement as an expense and reduces gross profit. A moving average of $9.67 on a 100-unit sale produces a $967 expense against revenue.

The same per-unit cost values whatever stays in the warehouse. 350 units at $9.67 shows $3,384.50 in inventory as a current asset on the balance sheet. Every dollar that leaves inventory through sales appears as an expense, and every dollar that stays appears as an asset, so the two statements stay in sync.

Errors run in both directions. Overstating inventory makes the business look more asset-rich than it is; understating cost of goods sold inflates profit. Both attract auditor attention and, because inventory valuation drives taxable income, IRS attention as well.2Office of the Law Revision Counsel. 26 USC 471 – General Rule for Inventories

Perpetual System Only

Moving average requires a perpetual inventory system because the recalculation has to happen in real time. A periodic system that only counts inventory at month-end or quarter-end lacks the transaction-level data between counts, so it cannot support this method. In a periodic setup, businesses use weighted average instead, which produces a single average at period-end. The math is the same in concept; the difference is frequency.

Returns and Inventory Adjustments

Customer returns add units back to inventory, but the cost you assign to those units is not necessarily what the customer paid. In most perpetual systems, returned goods re-enter inventory at the current moving average cost rather than the historical cost at the time of the original sale. If the average has shifted since that sale, the difference posts to a variance account instead of distorting the average.

Supplier returns work in reverse. Send 50 defective units back to a vendor with a current moving average of $9.67, and you pull $483.50 out of inventory value along with the 50 units. The per-unit average stays the same because you are removing units and dollars in the same ratio.

Cycle counts and audit adjustments follow the same logic. If a physical count shows 10 fewer units than the system, write those units off at the current moving average and record the shrinkage as an expense. The per-unit cost on what remains does not change.

Spoilage

Spoilage treatment depends on whether the loss was expected. Normal spoilage that is an inherent part of the process gets folded into the cost of the good units. If you routinely lose 5% of raw materials to contamination, the cost of that 5% stays in inventory value and spreads across the surviving units, effectively raising the per-unit cost.

Abnormal spoilage, such as a batch destroyed by a forklift accident or a power outage, gets expensed immediately as a period cost. Remove the damaged units and their cost from inventory and charge the loss to current earnings. The distinction is whether the loss was predictable and routine or unusual and avoidable.

When Market Value Falls Below Your Average

A moving average reflects what you paid, not what the inventory is worth today. Under GAAP, inventory measured at average cost must be carried at the lower of cost or net realizable value. Net realizable value is estimated selling price minus any remaining costs to complete and sell. If that number drops below your moving average, you write the inventory down to the lower figure and record an impairment loss.

Federal tax rules are similar but use different terminology. The IRS allows inventory to be valued at cost or market, whichever is lower, where “market” means current replacement cost, not selling price. Damaged, obsolete, or otherwise unsalable goods can be valued at their realistic selling price minus disposal costs, but the write-down needs backing evidence of actual sales or offers within 30 days of the inventory date.3Internal Revenue Service. Lower of Cost or Market (LCM)

Once inventory is written down, the reduced amount becomes the new cost basis going forward. You generally cannot mark it back up in a later period even if prices recover. GAAP allows one narrow exception: reversing a write-down taken earlier in the same fiscal year if the market recovers before year-end, and only up to the amount of the original loss.