FIFO Inventory Valuation & COGS Calculator

FIFO costs the units you sold out of your oldest inventory layers first, which leaves the newest costs — and in a rising market the highest ones — sitting in ending inventory. Enter your beginning inventory and up to four purchase layers in date order, say how many units you sold, and this calculator walks the layers in sequence to give you ending inventory, cost of goods sold, gross profit and the exact cost drawn out of every layer. It follows the cost-flow rules in FASB ASC 330 and IAS 2, and because FIFO is order-independent, the answer is identical under a periodic or a perpetual system.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Beginning inventory unitsUnits on hand at the start of the period — last period's closing count.100 units
Beginning inventory unit costThe cost per unit already assigned to that opening stock, not today's replacement cost.10 $
Purchase 1 — unitsUnits in your earliest purchase of the period.200 units
Purchase 1 — unit costInvoice price plus freight-in and duty, divided by units received.12 $
Purchase 2 — unitsUnits in your next purchase. Leave at zero if you only bought once.150 units
Purchase 2 — unit costLanded cost per unit for that second purchase.14 $
Units sold during the periodTotal units shipped or rung up. Under FIFO the sale dates do not affect the answer.300 units
Selling price per unitNet selling price per unit, so gross profit and gross margin can be derived.20 $
Purchase 3 — unitsA third layer, if you bought again later in the period.0 units
Purchase 3 — unit costLanded cost per unit for the third layer.0 $
Purchase 4 — unitsA fourth and newest layer. Combine anything beyond this into one weighted line.0 units
Purchase 4 — unit costLanded cost per unit for the newest layer.0 $

It returns

  • FIFO ending inventory — The newest unsold layers, valued at their own purchase costs. This is the balance-sheet figure.
  • Cost of goods sold
  • Gross profit
  • Gross margin
  • Cost of goods available for sale
  • Units left in inventory
  • Average cost per unit sold

The formula

COGS=koldestqkckandEI=GAFSCOGS
GAFS=kukck
GM%=RCOGSR×100

In plain text: Ending inventory (FIFO) = Σ over the newest unsold layers of uₖ · cₖ, and COGS = Cost of goods available − Ending inventory

  • COGSCost of goods sold: units taken from the oldest layers, at those layers' costs ($)
  • EIEnding inventory — the newest unsold layers at their own costs ($)
  • GAFSCost of goods available for sale: Σ uₖ · cₖ over every layer ($)
  • qₖUnits drawn out of layer k, working from the oldest layer forward (units)
  • uₖUnits originally in layer k (units)
  • cₖLanded cost per unit of layer k ($/unit)

FIFO is a cost-flow assumption, not a claim about which physical units moved. The layers are consumed in purchase order regardless of what the stock picker actually grabbed.

Updated Category Inventory, Receivables & Asset Accounting Verified against published test cases Reading time 12 min

What FIFO actually assumes

FIFO — first in, first out — assumes the first units you bought are the first ones charged to expense. It is an assumption about costs, not about boxes. You can pick stock from the back of the warehouse and still use FIFO, because the method governs which dollars leave inventory, not which cartons leave the dock.

That distinction matters because the physical units are usually indistinguishable while their costs are not. Buy 200 widgets at $12 in March and 150 at $14 in September, and you now hold 350 identical widgets carrying two different costs. When you sell 100, accounting has to decide which $12 or $14 follows them out. FIFO answers: the oldest first.

The consequence is systematic. Where costs drift upward, FIFO charges the cheapest, oldest layers to cost of goods sold and leaves the dearest, newest layers on the balance sheet. So FIFO reports the highest gross profit, the highest ending inventory and the highest tax bill of the three common cost-flow assumptions. LIFO does the opposite, and weighted average cost lands between them. FIFO is also the world's default: for interchangeable goods IAS 2 permits only FIFO and weighted average cost, so every IFRS filer uses one of the two.

How the layer walk works, step by step

Every FIFO calculation is the same four moves, and you can do them on a napkin.

One: build the pool. List beginning inventory and every purchase in date order, each with its units and its landed cost per unit. Landed cost means invoice price plus freight-in, duty and any non-recoverable tax — the costs ASC 330 and IAS 2 both require you to capitalise. Multiply units by unit cost in each row and add them up. That total is cost of goods available for sale, and it is the only pool the period has.

Two: split the pool by units. Units available minus units sold is units remaining. Nothing about cost enters yet; this is pure counting.

Three: walk the layers from the top. Take units out of layer 1 until it is exhausted, then move to layer 2, and so on until you have covered every unit sold. Multiply the units taken from each layer by that layer's own cost and add. That sum is cost of goods sold. Exactly one layer is usually partly consumed — the boundary layer — and it contributes to both COGS and ending inventory.

Four: take the residual. Ending inventory is the pool minus COGS. Compute it directly too, by valuing the leftover units at the newest layer costs — the two routes must agree to the penny, because the identity goods available = COGS + ending inventory is not optional. Notice what never appears anywhere above: selling price. Cost flow is independent of what you charged, and price only enters when you convert COGS into gross profit.

Worked example: 450 units, three layers, 300 sold

A hardware distributor starts the quarter with 100 units carried at $10. It buys 200 units at $12 in month one and 150 units at $14 in month three. It sells 300 units at $20 each.

  1. Build the pool. 100 × $10 = $1,000. 200 × $12 = $2,400. 150 × $14 = $2,100. Units available = 100 + 200 + 150 = 450. Cost of goods available = $1,000 + $2,400 + $2,100 = $5,500.
  2. Split by units. 450 available − 300 sold = 150 units remaining.
  3. Walk the layers. Layer 1 has 100 units; take all 100 at $10 = $1,000, leaving 200 units still to cost. Layer 2 has 200 units; take all 200 at $12 = $2,400, and the 300 units are covered. Layer 3 is untouched. Cost of goods sold = $1,000 + $2,400 = $3,400.
  4. Take the residual. Ending inventory = $5,500 − $3,400 = $2,100. Check it directly: the 150 leftover units are all from layer 3 at $14, and 150 × $14 = $2,100. The two agree.
  5. Convert to profit. Revenue = 300 × $20 = $6,000. Gross profit = $6,000 − $3,400 = $2,600. Gross margin = $2,600 ÷ $6,000 = 43.33%.
  6. Read the cost per unit. Average cost charged to expense = $3,400 ÷ 300 = $11.33. Average cost still on the balance sheet = $2,100 ÷ 150 = $14.00.

That last line is the whole story of FIFO in two numbers. You expensed inventory at $11.33 a unit while holding replacement-priced stock at $14.00. If sales continue at $20 and costs stay at $14, next quarter's margin falls from 43.3% to 30% with no change in pricing at all. FIFO does not create that squeeze; it delays your seeing it.

How to read the result

Read the two average costs against each other first. If average cost per unit sold sits well below ending inventory cost per unit, old cheap layers are flattering your gross margin and it will compress as they run out. That gap is the most useful diagnostic here, and it is invisible on the face of an income statement.

Next, sanity-check ending inventory against replacement cost. Under FIFO it should sit close to what you would pay today for the same goods; that is the method's main virtue. If your carrying value is materially above replacement cost, or above what you could sell the goods for net of selling cost, you owe a write-down — ASC 330 and IAS 2 both cap FIFO inventory at the lower of cost and net realisable value. The calculator flags the usual early warning: a selling price that has fallen below your newest layer cost.

Finally, judge gross margin against your own trailing periods, not an industry table. Cost-flow choice alone moves reported margin by several points on identical facts, so a cross-company comparison is meaningless until you read each inventory policy note. Within one company on one method the trend is highly informative — pair it with inventory turnover and days inventory outstanding to separate a pricing move from a cost move from simply holding stock longer.

FIFO results as units sold rises

One fixed cost pool — 100 units at $10, then 200 at $12, then 150 at $14, so 450 units costing $5,500 — costed under FIFO at seven different sales volumes. Selling price $20 per unit.
Units soldCost of goods soldEnding inventoryUnits leftAvg cost per unit soldGross margin
0$0$5,500450
50$500$5,000400$10.0050.0%
100$1,000$4,500350$10.0050.0%
150$1,600$3,900300$10.6746.7%
200$2,200$3,300250$11.0045.0%
300$3,400$2,100150$11.3343.3%
400$4,800$70050$12.0040.0%
450$5,500$00$12.2238.9%

Average cost per unit sold never falls as you sell deeper into newer layers, so gross margin never rises even though the selling price never moves — it is flat while you are still inside the $10 layer and drops with every step past it. At 450 units the FIFO answer equals the LIFO and weighted-average answers, because nothing is left to allocate.

The standards that govern this

US GAAP — FASB ASC 330, Inventory. Cost includes the expenditures and charges incurred to bring an article to its present condition and location. FIFO, LIFO and average cost are all acceptable, and your choice must be disclosed and applied consistently. FIFO and average-cost inventory is then carried at the lower of cost or net realisable value.

IFRS — IAS 2, Inventories. Cost is assigned using FIFO or weighted average cost, consistently across inventories of a similar nature and use. LIFO is not permitted, and inventory is measured at the lower of cost and net realisable value.

US tax. FIFO applies by default if you make no election. Adopting LIFO requires Form 970, and any later change of method generally needs IRS consent on Form 3115.

Mistakes that produce a wrong FIFO number

  • Entering purchases out of date order. FIFO is defined by sequence, so a later purchase listed above an earlier one gets consumed first and your COGS is wrong. Sort by receipt date, not invoice or payment date.
  • Using invoice price instead of landed cost. Freight-in, duty and non-recoverable taxes are inventory cost under both ASC 330 and IAS 2. Leaving them out understates every layer.
  • Netting a return against the wrong layer. Goods sent back to a vendor should reduce the layer they came from, at that layer's cost. Netting them against your newest purchase quietly shifts cost between COGS and inventory.
  • Ignoring goods in transit. Stock bought FOB shipping point is yours on the truck and must be entered as a layer; stock you sold FOB destination is still yours until it lands and stays in ending inventory.
  • Forgetting the lower-of-cost-or-net-realisable-value test. FIFO gives you cost, not value. Obsolete stock still needs writing down, and the write-down comes after the FIFO calculation, not instead of it.
  • Comparing a FIFO company with a LIFO company on gross margin. The spread can be several points on identical economics. If the LIFO filer discloses a LIFO reserve, add it back before comparing.

Why periodic and perpetual FIFO give the same answer

Under FIFO a periodic system and a perpetual system produce identical cost of goods sold and identical ending inventory. That is not true of the other methods, so it is worth knowing why.

In a perpetual system you cost each sale as it happens, taking from the oldest layer available at that moment. In a periodic system you cost every sale at once at period end, taking from the oldest layer available overall. Under FIFO both give the same assignment: a layer bought after a sale can never be older than one bought before it, so it can never jump the queue. Consumption order is fixed by purchase order alone, and when you look does not change it.

LIFO and weighted average break this. Under LIFO, "most recent" depends on when you evaluate, so a June sale draws from a June layer under perpetual but from a December layer under periodic. That is why this calculator can stay silent about sale dates.

Choosing between FIFO, LIFO and weighted average

Pick FIFO when you want a balance sheet that reflects current costs, when you report under IFRS, or when inventory genuinely rotates and a stale layer would mislead. It is the easiest method to audit and to explain.

Pick LIFO only as a US filer facing sustained cost inflation, where the deferred tax is worth the complexity. LIFO strands decades-old costs in inventory, binds you to the conformity rule in your financial statements, and can reverse violently if you let stock run down.

Pick weighted average cost when units are physically commingled and layers are artificial — bulk liquids, grain, fasteners, fuel. It smooths cost volatility and is allowed under both GAAP and IFRS.

Whichever you choose, the identity behind all three is the one the COGS calculator uses: beginning inventory plus additions minus ending inventory. The methods differ only in how they value that final term — and because ending inventory rolls forward as next period's beginning inventory, a cost-flow choice affects two years of reported profit, not one. Feed the COGS figure into cash conversion cycle work to see how long your money stays tied up in stock.

Key terms

Cost layer
A batch of units acquired at one unit cost. Layers are the unit of account for FIFO and LIFO; weighted average dissolves them.
Cost of goods available for sale
Beginning inventory cost plus all purchase layer costs — the pool divided between COGS and ending inventory.
Landed cost
Invoice price plus freight-in, duty and other costs of getting goods to their present location and condition.
Net realisable value
Estimated selling price less the costs of completion and sale. FIFO inventory cannot be carried above it.

Frequently asked questions

How do I calculate ending inventory using FIFO?

Value the units you still hold at the costs of your most recent purchases, working backwards. Count the leftover units, take them from the newest layer first, and if that layer is not big enough, keep stepping back to older layers until you have covered every remaining unit. Multiply each slice by its layer cost and add. Cross-check by subtracting cost of goods sold from cost of goods available for sale — the two routes must give the same number.

Does FIFO give higher or lower profit than LIFO?

Higher, whenever unit costs are rising — which is the normal case. FIFO charges your oldest and cheapest layers to expense, so cost of goods sold is smaller and gross profit is larger than under LIFO on the same facts. On the worked example above, FIFO reports $2,600 of gross profit against LIFO's $2,100, a $500 difference on identical purchases and identical sales. If costs are falling the relationship reverses and FIFO reports the lower profit.

Do I need to track which physical units I sold?

No. FIFO is an assumption about cost flow, not a tracking requirement, so you never match a serial number to a layer. The one method that does demand unit-level tracking is specific identification, which GAAP and IFRS both allow for goods that are not ordinarily interchangeable — real estate, vehicles, fine art, custom machinery.

Is FIFO allowed under IFRS?

Yes, and it is one of only two permitted formulas. IAS 2 allows FIFO or weighted average cost and prohibits LIFO outright. The chosen formula must be applied consistently to inventories of similar nature and use, and a change is a change in accounting policy requiring retrospective restatement.

What happens if I sell more units than the layers contain?

The calculator caps cost of goods sold at the whole pool, reports zero ending inventory, and flags an error, because you cannot expense inventory you never had. In practice this almost always means a purchase layer is missing — often goods received near period end that were counted physically but not yet entered — or beginning inventory was understated. Fix the input rather than accepting the capped result.

Should freight-in go into the layer cost?

Yes. Inbound freight is part of the cost of bringing goods to their present location, so it belongs in inventory cost under ASC 330, IAS 2 and the US uniform capitalisation rules. Divide each shipment's freight by the units in that shipment and add it to the invoice price. Outbound freight to your customer is a selling expense and stays out of inventory entirely.

What is a normal gap between average cost sold and average cost on hand?

For fast-moving goods it should be small — a few percent — because you turn inventory over before costs can drift far apart. A gap of 15% or more usually means either that input costs moved sharply or that your inventory is turning slowly enough for old layers to persist. Neither is inherently wrong, but a wide gap is a reliable signal that next period's margin will differ from this period's, so plan pricing accordingly.

Can I switch from FIFO to LIFO or back?

Not freely. For US book purposes it is a change in accounting principle, requiring justification that the new method is preferable and retrospective application in comparative statements. For tax it is a change in accounting method that generally needs IRS consent on Form 3115, and electing LIFO also requires Form 970. Under IFRS you cannot elect LIFO at all.

References

  • FASB Accounting Standards Codification Topic 330, Inventory — Financial Accounting Standards Board
  • IAS 2 InventoriesIFRS Foundation / International Accounting Standards Board
  • Publication 538, Accounting Periods and MethodsInternal Revenue Service
  • Intermediate Accounting, 18th ed. (inventory valuation chapters) — Wiley (Kieso, Weygandt & Warfield)