acalculator

What is my FIFO cost of goods sold?

Enter your beginning inventory and each purchase, oldest first, with the units and the cost per unit, then the units you sold. The calculator gives the cost of goods sold and ending inventory by FIFO, LIFO and weighted average, and the gross margin if you add the sales.

Your numbers

Inventory layers, oldest first
Row 1
Row 2
Row 3
Cost of goods sold (FIFO)
$7,200.00

Selling 300 units costs $7,200.00 by FIFO, $9,360.00 by LIFO and $8,284.62 at the weighted average.

Ending inventory (FIFO)
$8,955.00
Cost of goods sold (LIFO)
$9,360.00
Ending inventory (LIFO)
$6,795.00
Cost of goods sold (weighted average)
$8,284.62
Ending inventory (weighted average)
$7,870.38
Weighted average cost per unit
$27.6154
Cost of goods available
$16,155.00
Units available
585
Units left
285
Gross margin (FIFO)
$4,140.00
Gross margin (LIFO)
$1,980.00
Gross margin (weighted average)
$3,055.38

Cost of goods sold (FIFO): $7,200.00. Selling 300 units costs $7,200.00 by FIFO, $9,360.00 by LIFO and $8,284.62 at the weighted average.

The results are estimates for information only. They are not financial, tax, or legal advice. Check the numbers with your lender or a qualified professional before you decide. Terms of use

How to calculate

Computes cost of goods sold and ending inventory by FIFO, LIFO and weighted average from your beginning inventory and purchases, by the periodic method, with gross margin when you add sales.

Example with the default inputs (Inventory layers, oldest first [Units 150, Cost per unit $21.00; Units 225, Cost per unit $27.00; Units 210, Cost per unit $33.00], Units sold 300, Sales revenue $11,340.00): Selling 300 units costs $7,200.00 by FIFO, $9,360.00 by LIFO and $8,284.62 at the weighted average.

Method: Cost of goods available = Σ units × cost. FIFO cost of goods sold = the units sold taken from the oldest layers first; LIFO = from the newest layers first; weighted average = units sold × (cost of goods available ÷ units available). Ending inventory = cost of goods available − cost of goods sold. Gross margin = sales − cost of goods sold.

  • The periodic method: every purchase of the period is counted before the units sold are costed. FIFO gives the same result under the perpetual method; LIFO and the weighted (moving) average can differ.
  • Layers are listed oldest first, starting with the beginning inventory.
  • Arithmetic is exact on the typed decimals, with no rounding of the average cost per unit; money shows to the cent, halves up.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. Inventory layers, oldest first 150 21; 225 27; 210 33, Units sold 300, Sales revenue $11,340.00 gives Cost of goods sold (FIFO) $7,200.00, Ending inventory (FIFO) $8,955.00, Cost of goods sold (LIFO) $9,360.00, Ending inventory (LIFO) $6,795.00, Cost of goods available $16,155.00, Units available 585, Units left 285, Gross margin (FIFO) $4,140.00, Gross margin (LIFO) $1,980.00, Weighted average cost per unit $27.6154, Cost of goods sold (weighted average) $8,284.62, Ending inventory (weighted average) $7,870.38, Gross margin (weighted average) $3,055.38.Source: OpenStax, Principles of Financial Accounting, 10.2 Calculate the Cost of Goods Sold and Ending Inventory Using the Periodic Method (Spy Who Loves You Corporation: 150 units at $21, 225 at $27, 210 at $33; 300 units sold for $11,340; FIFO cost of goods sold $7,200, ending inventory $8,955, gross margin $4,140; LIFO $9,360, $6,795, $1,980). https://openstax.org/books/principles-financial-accounting/pages/10-2-calculate-the-cost-of-goods-sold-and-ending-inventory-using-the-periodic-method
  2. Inventory layers, oldest first 100 10; 100 12, Units sold 150 gives Cost of goods sold (FIFO) $1,600.00, Ending inventory (FIFO) $600.00, Cost of goods sold (LIFO) $1,700.00, Ending inventory (LIFO) $500.00, Cost of goods sold (weighted average) $1,650.00, Weighted average cost per unit $11.0000.Source: OpenStax, Principles of Financial Accounting, 10.2 Calculate the Cost of Goods Sold and Ending Inventory Using the Periodic Method (Spy Who Loves You Corporation: 150 units at $21, 225 at $27, 210 at $33; 300 units sold for $11,340; FIFO cost of goods sold $7,200, ending inventory $8,955, gross margin $4,140; LIFO $9,360, $6,795, $1,980). https://openstax.org/books/principles-financial-accounting/pages/10-2-calculate-the-cost-of-goods-sold-and-ending-inventory-using-the-periodic-method (the periodic method)
  3. Inventory layers, oldest first 40 2.5; 60 3.1; 50 3.45, Units sold 0 gives Cost of goods sold (FIFO) $0.00, Ending inventory (FIFO) $458.50, Cost of goods sold (LIFO) $0.00, Ending inventory (LIFO) $458.50, Ending inventory (weighted average) $458.50, Units left 150.Source: OpenStax, Principles of Financial Accounting, 10.2 Calculate the Cost of Goods Sold and Ending Inventory Using the Periodic Method (Spy Who Loves You Corporation: 150 units at $21, 225 at $27, 210 at $33; 300 units sold for $11,340; FIFO cost of goods sold $7,200, ending inventory $8,955, gross margin $4,140; LIFO $9,360, $6,795, $1,980). https://openstax.org/books/principles-financial-accounting/pages/10-2-calculate-the-cost-of-goods-sold-and-ending-inventory-using-the-periodic-method

How it works

List the layers oldest first: the beginning inventory, then each purchase in date order. With layer k holding uₖ units at cost cₖ each, and S units sold:

  • Units available U = Σ uₖ, and units left = U − S
  • Cost of goods available A = Σ uₖ × cₖ
  • FIFO cost of goods sold = the S units taken from the first layers: whole layers in order, then part of the next layer at its cost
  • LIFO cost of goods sold = the S units taken the same way from the last layer backwards
  • Weighted average cost per unit = A ÷ U, and weighted average cost of goods sold = S × A ÷ U
  • Ending inventory = A − cost of goods sold, by each method (for the average: (U − S) × A ÷ U)
  • Gross margin = sales revenue − cost of goods sold, by each method, when you enter the sales revenue

Rules:

  • Units are 0 or more (at most 1 trillion a layer), costs per unit $0 or more (at most $1 billion), units sold 0 or more (at most 20 trillion), and sales revenue $0 or more (at most $1 quadrillion). A layer with 0 units adds nothing. The table has 1 to 20 layers.
  • Units available of 0 give no answer: "Add a layer with more than 0 units."
  • Units sold above the units available give no answer: "The units sold are more than the units available: check the layers and the units sold."
  • Gross margins show only when you enter the sales revenue; they may be negative.
  • A result that is not 0 but too small to show as a number gives no answer with "NAME is too small to show as a number.", where NAME is the first such result in this order: "FIFO cost of goods sold", "FIFO ending inventory", "LIFO cost of goods sold", "LIFO ending inventory", "Weighted average cost of goods sold", "Weighted average ending inventory", "The weighted average cost per unit", "The cost of goods available", "The units left", "FIFO gross margin", "LIFO gross margin", "Weighted average gross margin".
  • The rule on 0 units comes before the rule on units sold, and both come before the results.
  • The arithmetic is exact on the decimals you type, and the weighted average cost per unit is not rounded before it is used. Money shows to the cent and the average cost per unit to 4 decimals, with halves rounded up (away from 0).

Assumptions

  • The periodic method: all the purchases of the period are counted before the units sold are costed.
  • Every unit in a layer costs the same.

Worked examples by hand

Spy Who Loves You Corporation, July. Layers: 150 at $21 ($3,150), 225 at $27 ($6,075), 210 at $33 ($6,930). Goods available: 585 units, $16,155. 300 units sold for $11,340; 285 left.

  • FIFO: 150 × 21 + 150 × 27 = $7,200; ending inventory 16,155 − 7,200 = $8,955; gross margin 11,340 − 7,200 = $4,140.
  • LIFO: 210 × 33 + 90 × 27 = $9,360; ending inventory $6,795; gross margin $1,980.
  • Weighted average: 16,155 ÷ 585 = 27.61538…, shown as $27.6154 a unit. Cost of goods sold = 300 × 16,155 ÷ 585 = $8,284.62; ending inventory = 285 × 16,155 ÷ 585 = $7,870.38; gross margin = $3,055.38. OpenStax rounds the unit cost to $27.62 first and gets $8,283, $7,872 and $3,057.

Two layers. 100 at $10 and 100 at $12, 150 sold. FIFO = 100 × 10 + 50 × 12 = $1,600 (ending $600); LIFO = 100 × 12 + 50 × 10 = $1,700 (ending $500); average = 2,200 ÷ 200 = $11 a unit, × 150 = $1,650.

Nothing sold. 40 at $2.50, 60 at $3.10 and 50 at $3.45: cost of goods available = 100 + 186 + 172.50 = $458.50. Cost of goods sold is $0 by every method, and ending inventory is $458.50.

Other questions people ask

What is FIFO?

FIFO, first in, first out, is an inventory costing method that assumes the oldest units are sold first. Cost of goods sold carries the oldest costs, and ending inventory carries the newest ones.

How do I calculate cost of goods sold with FIFO?

Take the units sold from your oldest layer first, then the next, and add up their costs. Spy Who Loves You Corporation sold 300 units from 150 at $21 and 225 at $27 (then 210 at $33): 150 × 21 + 150 × 27 = 3,150 + 4,050 = $7,200.

How do I calculate ending inventory with FIFO?

Subtract FIFO cost of goods sold from the cost of all goods available, or cost the units left at the newest prices. Spy had $16,155 of goods available, so its FIFO ending inventory was 16,155 − 7,200 = $8,955: 210 units at $33 and 75 at $27.

How is LIFO different?

LIFO, last in, first out, takes the units sold from the newest layer first. For Spy: 210 × 33 + 90 × 27 = 6,930 + 2,430 = $9,360 of cost of goods sold, leaving $6,795 in ending inventory.

How does the weighted average method work?

Divide the cost of goods available by the units available, then multiply by the units sold. Spy: 16,155 ÷ 585 = $27.6154 a unit, and 300 × 27.6154 = $8,284.62. OpenStax rounds the unit cost to $27.62 first and shows $8,283; this calculator keeps the exact unit cost.

Which method gives the highest profit?

When costs are rising, FIFO matches the cheapest units against sales, so it gives the lowest cost of goods sold and the highest gross margin; LIFO gives the opposite. With $11,340 of sales, Spy’s gross margin was $4,140 by FIFO and $1,980 by LIFO.

Does it matter if I use the periodic or the perpetual method?

Not for FIFO: the oldest units go first either way, so the result is the same. LIFO and the average cost can differ, because the perpetual method costs each sale with only the purchases made before it. This calculator uses the periodic method, counting all the purchases of the period first.