Tabellab

Periodic FIFO: Cost Layers, COGS & Ending Inventory

Lesson 1 of 20Lab

All lessons
  1. Periodic FIFO: Cost Layers, COGS & Ending InventoryLabFree
  2. Periodic LIFO and the LIFO ReserveLab Locked
  3. Weighted Average Cost with Landed Cost (Discounts & Freight-in)Lab Locked
  4. Perpetual Moving Average: the Running Stock CardLab Locked
  5. FIFO vs Weighted Average vs LIFO: Profit & Tax in Rising PricesLab Locked
  6. Lower of Cost and NRV: Item by Item, by Group, and the ReversalLab Locked
  7. Stock Count Adjustments & ShrinkageLab Locked
  8. Inventory Ratios: Turnover, Days in Inventory & GMROILab Locked
  9. Perpetual FIFO: Costing Each Sale from the Oldest LayersLab Locked
  10. Returns and Allowances: Net Purchases, Customer Returns and Their Journal EntriesLab Locked
  11. Specific Identification: Serial-Numbered Kayaks and Why the Method Is RestrictedLab Locked
  12. Import Landed Cost: Exchange Rates, Duty and Shared Freight Split Across SKUsLab Locked
  13. LIFO Liquidation: When Old Cheap Layers Inflate ProfitLab Locked
  14. Dollar-Value LIFO: Price Indexes, Base-Year Layers and a DecreaseLab Locked
  15. Periodic vs Perpetual: Year-End COGS Entries and the Shrinkage You Cannot SeeLab Locked
  16. Inventory Roll-Forward: Reconciling Movements, the Stock Report and the LedgerLab Locked
  17. A Workshop's Three Inventories: Raw Materials, Work in Progress and Finished GoodsLab Locked
  18. The Inventory Purchases Budget: Stock Cover, Seasonal Peaks and Buying AheadLab Locked
  19. Inventory and Cash: Days Inventory Outstanding and the Cash Conversion CycleLab Locked
  20. Final Project: Year-End Inventory Close and Valuation SummaryLab Locked

You are not signed in — the lab works, but your progress is not saved. Sign up

Lesson 1 of 20 is free. Unlock all 20 hands-on labs, the final exam and your certificate.

Buy course — CHF 9.90
Loading the spreadsheet…

Why inventory valuation decides your profit

A retailer buys the same product several times a year, and almost never at the same price. At year end some of those units have been sold and some are still on the shelf. Which purchase price belongs to the units sold, and which to the units left? The answer is not a detail. It decides the cost of goods sold, and therefore gross profit and the tax bill, and it decides the inventory figure on the balance sheet that lenders and investors read. Two companies with identical sales, identical purchases and identical shelves can report different profits simply because they value their stock differently.

This free first lesson of Inventory Accounting: FIFO, LIFO, Weighted Average & Valuation is for bookkeepers and accountants in retail, wholesale and manufacturing, for small-business owners who hold stock, and for accounting students who need to solve FIFO questions quickly and correctly. It starts with the most widely used cost formula, FIFO, first in, first out, in a periodic inventory system, and it shows how to make Excel allocate units to cost layers automatically instead of by hand.

In the lab above you work for Cedar & Pine Outfitters, a fictional outdoor-gear retailer. Its 40-litre trail backpack was bought five times in 2026 at rising prices, from $42.00 to $50.00 a unit. The year-end count found 180 backpacks left. Your job is to work out how many units were sold from each purchase, what those units cost, what the remaining stock is worth, and what gross margin the product earned.

The core idea: cost layers and the flow of cost

Every purchase at a different price creates a cost layer: a number of units at one unit cost. The opening inventory is simply the first layer. Add all the layers together and you get the goods available for sale, both in units and in dollars. For the backpacks that is 900 units costing $41,630.

Everything available is either sold or still in stock at year end, so the cost of goods available has to be split in two: cost of goods available = cost of goods sold (COGS) + ending inventory. That identity is the backbone of inventory accounting, and it is also your best check: whatever method you use, the two parts must add back to $41,630.

In a periodic system the business does not track each sale against stock during the year. It counts what is left at year end and works backwards: units sold = units available − units counted. For Cedar & Pine that is 900 − 180 = 720 backpacks. Only after the count are the units sold assigned to the layers. (A perpetual system, which updates the stock card at every sale, is covered in lesson 4.)

The cost formula decides the order in which layers are used up. FIFO assumes the oldest units leave first, which matches how most shops physically rotate stock. So the 720 units sold come first from the opening 120, then the March 200, then the June 260, and the last 140 from the September layer. What remains, the ending inventory, is the newest stock: 40 units from September and all 140 from November. That is why FIFO shows inventory on the balance sheet close to current replacement cost.

FIFO and weighted average cost are permitted under both IFRS (IAS 2) and US GAAP. LIFO is not permitted under IFRS but is allowed under US GAAP, which is why you meet it in lesson 2. The cost formula is a policy choice that must be applied consistently to inventories of a similar nature and use.

Worked example: FIFO for the trail backpack

The table shows the five layers, the cost of each and the units FIFO takes from each one. The formula in E2 is =MIN(B2,$B$10-SUM(E$1:E1)), copied down to E6. Read it as: take the whole layer, but never more than the units still missing. $B$10 is the total sold (720) and SUM(E$1:E1) is a growing range that adds up what the layers above have already supplied. In E2 that range only contains the header text, which SUM treats as 0.

LayerUnitsUnit costCost USD =B*CFIFO units soldFIFO cost of units sold
1 Jan · opening inventory12042.005,040.001205,040.00
10 Mar · purchase20044.508,900.002008,900.00
15 Jun · purchase26046.0011,960.0026011,960.00
20 Sep · purchase18048.508,730.001406,790.00
25 Nov · purchase14050.007,000.0000.00
Goods available90041,630.0072032,690.00

Backpack cost layers 2026: units sold vs units left under FIFO0501001502002503001201 Jan@ $42.0020010 Mar@ $44.5026015 Jun@ $46.0018020 Sep@ $48.5014025 Nov@ $50.00Units sold (FIFO, oldest first)Units left in ending inventory
FIFO empties the oldest layers first. Only the September layer is split: 140 units sold, 40 left. The whole November layer is still on the shelf.

From the allocation the results follow in four lines. Sales revenue is 720 × $79.00 = $56,880. FIFO cost of goods sold is =SUMPRODUCT(C2:C6,E2:E6) = $32,690, because SUMPRODUCT multiplies each layer's units sold by its own unit cost and adds the results. Ending inventory is =D7-B14 = $8,940. You can prove it from the other side: 40 × $48.50 + 140 × $50.00 = $1,940 + $7,000 = $8,940. Gross profit is =B13-B14 = $24,190, and gross margin is =B16/B13 = 42.5%.

Result 2026 (FIFO)USDFormula
Sales revenue56,880.00=B10*B11
Cost of goods sold32,690.00=SUMPRODUCT(C2:C6,E2:E6)
Ending inventory8,940.00=D7-B14
Gross profit24,190.00=B13-B14
Gross margin42.5%=B16/B13
Check: units allocated720=SUM(E2:E6) must equal B10

How would the other cost formulas compare? With weighted average cost, every unit costs $41,630 / 900 = $46.26 (rounded), so COGS is $33,304 and ending inventory $8,326. With LIFO, the newest layers are sold first, so COGS is $33,920 and ending inventory only $7,710, made of the 120 opening units and 60 from March. Prices rose all year, so FIFO, which charges the oldest and cheapest costs to COGS, reports the highest profit and the highest inventory, and LIFO the lowest.

Same backpacks, three cost formulas (USD, rising prices)$0$10k$20k$30k$40k$32,690$8,940$24,190FIFO$33,304$8,326$23,576Weighted average$33,920$7,710$22,960LIFOCost of goods soldEnding inventoryGross profit
With rising prices FIFO shows the highest gross profit and inventory, LIFO the lowest, and weighted average sits between them. With falling prices the order would reverse.

The differences look small for one product: $1,230 of gross profit between FIFO and LIFO. Across thousands of products and several years of inflation they can become large, which is why the choice of cost formula is disclosed in the accounting policies, and why a change of method is treated as a change in accounting policy rather than something a company can switch each year to flatter the results.

How to do it in Excel, step by step

  1. List the layers in date order, oldest at the top: date and description in column A, units in B, unit cost in C. FIFO depends on this order, so sort by date first with Data › Sort if the purchases came from a system export.
  2. In D2 enter =B2*C2 and fill down to D6 with Ctrl+D. Total units and cost in row 7 with =SUM(B2:B6) and =SUM(D2:D6) (Alt+= is AutoSum).
  3. Enter the year-end count in B9 and calculate units sold in B10 with =B7-B9.
  4. In E2 enter =MIN(B2,$B$10-SUM(E$1:E1)). Use F4 to lock B10 fully and press it until E$1 has a dollar sign only before the row, so the start of the range stays fixed while the end moves down.
  5. Fill E2 down to E6. Check that E7 (=SUM(E2:E6)) equals B10. If the layers cannot cover the units sold, the count or the purchases are wrong.
  6. In B14 enter =SUMPRODUCT(C2:C6,E2:E6) for FIFO cost of goods sold.
  7. In B15 enter =D7-B14 for ending inventory, in B16 =B13-B14 for gross profit and in B17 =B16/B13 for gross margin. Format B17 as a percentage with Ctrl+Shift+%.
  8. Show the formulas with Ctrl+` and confirm that every cell in E2:E6 follows the same pattern, with only the end of the SUM range changing.
If you prefer a formula that cannot go negative even when the data are wrong, wrap the second argument in MAX: =MIN(B2,MAX(0,$B$10-SUM(E$1:E1))). It returns 0 for every layer after the units sold are fully covered.

Periodic versus perpetual, and why FIFO does not care

A useful fact for exams and for practice: under FIFO, the periodic and perpetual systems give the same COGS and ending inventory. Because the oldest units always leave first, it does not matter whether you assign them sale by sale during the year or all at once after the count. That is not true for the average method, where a perpetual system recalculates the average after every purchase (the moving average you build in lesson 4) and can give a different result from the periodic weighted average.

The periodic system has one weakness you should keep in mind. Because units sold are derived from the count, anything that leaves the store without being sold, such as theft, damage or a counting error, is silently treated as a sale and buried in COGS. A perpetual system knows what should be on the shelf, so the difference between the records and the count becomes visible as shrinkage. Lesson 7 shows how to separate and book it.

What belongs in the unit cost

The lab gives you a ready-made unit cost for every layer, but in practice someone has to build it. Under IAS 2, and similarly under US GAAP, the cost of purchased inventory includes the purchase price, import duties and other non-recoverable taxes, transport and handling needed to bring the goods to their present location, and other directly attributable costs, while trade discounts and rebates are deducted. Freight paid to bring backpacks into the warehouse, for example, is part of their cost. Freight paid to deliver them to customers is a selling expense and is not.

Getting the unit cost right matters as much as getting the cost formula right. If inbound freight is booked straight to an expense account, every layer is understated, COGS and ending inventory are both too low, and the gross margin looks better than it is in the year the goods are bought. Lesson 3 builds this landed cost from list price, trade discount and freight-in, so each layer carries its full cost before FIFO or the average method ever touches it.

Course cover for Inventory Accounting: FIFO, LIFO, Weighted Average and Valuation
Inventory Accounting in Excel: one outdoor retailer, every common cost formula, NRV write-downs and inventory ratios.

Common mistakes and how to spot them

  • Taking the whole layer every time. =B5 in E5 sells all 180 September units, although the older layers already covered 580 of the 720. The check E7 = B10 fails immediately.
  • Valuing all units sold at one price. =B10*C2 uses only the oldest cost. Each layer has its own cost, so use SUMPRODUCT.
  • Mixing up FIFO and weighted average. =D7/B7*B10 is average cost, not FIFO. It gives $33,304 instead of $32,690.
  • Valuing ending inventory at the oldest cost. Under FIFO the units left are the newest ones. =B9*C2 is the wrong end of the list.
  • Assuming the newest layer covers all ending units. =B9*C6 values 180 units at $50, but only 140 came in November. Use =D7-B14 or add the leftover of each layer.
  • Wrong anchoring in the growing range. SUM(E1:E1) without the dollar sign moves both ends when copied, so each layer only sees the one above. Look for E$1 in every copied formula.
  • Layers not in date order. FIFO relies on the order of rows. A purchase list sorted by supplier or amount gives a plausible-looking but wrong result.

Quick reference: the Excel tools in this lesson

Function or shortcutWhat it doesExample from the lab
MIN(a, b)Returns the smaller value=MIN(B2,$B$10-SUM(E$1:E1))
SUM(E$1:E1)Growing (running) range: start fixed, end movesUnits already taken from earlier layers
MAX(0, x)Stops a result from going negative=MIN(B6,MAX(0,$B$10-SUM(E$1:E5)))
SUMPRODUCT(a, b)Multiplies pairs and adds them=SUMPRODUCT(C2:C6,E2:E6) → 32,690
=D7/B7Weighted average unit cost41,630 / 900 → 46.26
F4Cycles $E$1, E$1, $E1, E1Anchor the start of the running range
Ctrl+DFill downCopy E2 to E3:E6
Ctrl+`Show formulasCheck the pattern in E2:E6

Real-world uses

  • Year-end close for a small retailer. Many small businesses run a periodic system: they count at year end and need COGS and closing stock for the accounts. This sheet does exactly that, one product per block or with a product column added.
  • Checking the ERP. Inventory systems calculate FIFO automatically, but the result is only as good as the data. Rebuilding one product in Excel is a quick way to confirm that the system's layers and costs are right.
  • Pricing decisions. FIFO cost lags behind current purchase prices when prices rise. Seeing the September and November costs in the ending inventory reminds a buyer that the next units will cost $50, not $46.
  • Audit and due diligence. Auditors and buyers of a business test inventory valuation by recalculating a sample of products. The same MIN and SUMPRODUCT logic makes the recalculation fast.
  • Exams. FIFO, LIFO and weighted average questions appear in most introductory and intermediate accounting exams. A formula-driven layout turns a long manual table into a check you can trust.

What you will build in the rest of this course

This lesson is free. The other 19 labs are part of the full course, available as a one-time purchase of $9.90, and they keep working with Cedar & Pine Outfitters so you can see how each method changes the same numbers.

Periodic LIFO and the LIFO Reserve. You value the same backpacks newest layer first and measure the LIFO reserve, the gap between FIFO and LIFO inventory that US companies using LIFO disclose.

Weighted Average Cost with Landed Cost (Discounts & Freight-in). You build the true cost of each jacket purchase from list price, trade discount and freight-in, then value COGS and ending inventory at weighted average cost.

Perpetual Moving Average: the Running Stock Card. You keep a perpetual stock card for camp stoves, costing every sale at the current average and updating the average after every purchase.

FIFO vs Weighted Average vs LIFO: Profit & Tax in Rising Prices. You put the three formulas side by side and chart how each one changes gross profit and income tax.

Lower of Cost and NRV: Item by Item, by Group, and the Reversal. You test six product lines for a write-down to net realisable value, see how a group test can hide losses, and book the write-down and a later partial reversal.

Stock Count Adjustments & Shrinkage. You compare the year-end count with the perpetual records, separate an unrecorded receipt from real shrinkage, and book both.

Inventory Ratios: Turnover, Days in Inventory & GMROI. You measure how fast each category sells its stock and how much gross margin every dollar of inventory earns. A final exam leads to the Tabellab Certified Inventory Accountant certificate.

Summary

Inventory valuation splits the cost of goods available between what was sold and what is left. In a periodic system you count the stock, derive the units sold, and then let the cost formula decide which layers they came from. Under FIFO the oldest layers go first, so one copied formula, =MIN(B2,$B$10-SUM(E$1:E1)), does the allocation, SUMPRODUCT prices it, and ending inventory is whatever is left. For Cedar & Pine's backpacks that means COGS of $32,690, ending inventory of $8,940 and a gross margin of 42.5%.

Now scroll up to the lab and build it yourself. Allocate the 720 units to the layers, price them, and let the Coach confirm each cell, including the September layer, the one that is only partly sold and the one most people get wrong the first time.

Frequently asked questions

How do you calculate FIFO cost of goods sold?

List the purchase layers from oldest to newest, assign the units sold to the oldest layers first until all units sold are covered, then multiply each layer's units sold by its unit cost and add them up. In Excel that is =SUMPRODUCT(unit costs, units sold per layer).

How do you calculate FIFO ending inventory?

Ending inventory is the cost of goods available for sale minus FIFO cost of goods sold. Under FIFO the units left are the newest purchases, so you can also value them at the latest layers' costs as a check.

What Excel formula allocates units to FIFO layers?

Use =MIN(B2,$B$10-SUM(E$1:E1)) in the first layer and copy it down. Each layer gives its full quantity but never more than the units sold still not covered by the layers above.

Does FIFO give higher profit than LIFO?

When purchase prices are rising, yes: FIFO charges the older, cheaper costs to cost of goods sold, so gross profit and ending inventory are higher than under LIFO. When prices fall, the order reverses.

Is LIFO allowed under IFRS?

No. IAS 2 permits FIFO and weighted average cost (and specific identification for items that are not interchangeable) but does not permit LIFO. US GAAP still allows LIFO.

What is the difference between periodic and perpetual inventory?

A periodic system counts stock at the end of the period and derives the units sold from the count. A perpetual system updates the inventory record with every purchase and sale. Under FIFO both give the same result, under average cost they can differ.

Keep going: Inventory Accounting: FIFO, LIFO, Weighted Average & Valuation

This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time CHF 9.90.

  1. Periodic LIFO and the LIFO Reserve
  2. Weighted Average Cost with Landed Cost (Discounts & Freight-in)
  3. Perpetual Moving Average: the Running Stock Card
  4. FIFO vs Weighted Average vs LIFO: Profit & Tax in Rising Prices
  5. Lower of Cost and NRV: Item by Item, by Group, and the Reversal
  6. Stock Count Adjustments & Shrinkage
  7. Inventory Ratios: Turnover, Days in Inventory & GMROI
  8. Perpetual FIFO: Costing Each Sale from the Oldest Layers
  9. Returns and Allowances: Net Purchases, Customer Returns and Their Journal Entries
  10. Specific Identification: Serial-Numbered Kayaks and Why the Method Is Restricted
  11. Import Landed Cost: Exchange Rates, Duty and Shared Freight Split Across SKUs
  12. LIFO Liquidation: When Old Cheap Layers Inflate Profit
  13. Dollar-Value LIFO: Price Indexes, Base-Year Layers and a Decrease
  14. Periodic vs Perpetual: Year-End COGS Entries and the Shrinkage You Cannot See
  15. Inventory Roll-Forward: Reconciling Movements, the Stock Report and the Ledger
  16. A Workshop's Three Inventories: Raw Materials, Work in Progress and Finished Goods
  17. The Inventory Purchases Budget: Stock Cover, Seasonal Peaks and Buying Ahead
  18. Inventory and Cash: Days Inventory Outstanding and the Cash Conversion Cycle
  19. Final Project: Year-End Inventory Close and Valuation Summary

Buy course — CHF 9.90 See the full course