ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Projects
  3. FIFO Inventory Costing in Excel, Step by Step

FIFO Inventory Costing in Excel, Step by Step

By ExcelReady Team·Updated November 3, 2026·6 min read

The short answer

FIFO (first in, first out) costs each sale at the price of the oldest stock first. In Excel, list purchase lots oldest to newest, use =MIN(lot qty, MAX(0, units sold - units in earlier lots)) to see how many units each lot supplies, then =SUMPRODUCT(unit costs, units used) gives the cost of goods sold.

Key takeaways

  • FIFO assumes the oldest units are sold first, so each sale is costed at the oldest purchase prices still in stock.
  • List purchase lots in date order, oldest at the top. The formulas depend on that order.
  • =MIN(B2,MAX(0,$G$2-SUM(B$1:B1))) works out how many units each lot supplies to the sales.
  • =SUMPRODUCT(C2:C4,D2:D4) multiplies units used by unit cost and adds them up: that is the cost of goods sold.
  • Ending inventory value is total purchase cost minus cost of goods sold.
On this page+
  1. What FIFO inventory means
  2. Set up the purchase lots table
  3. How many units each lot supplies: MIN and MAX
  4. Cost of goods sold with SUMPRODUCT
  5. Ending inventory value
  6. FIFO vs weighted average cost
  7. Keep the FIFO sheet working each month
  8. Practise it

FIFO inventory costing in Excel takes one small table and two formulas. FIFO means first in, first out: when you sell, the oldest stock is assumed to go first, so each sale is costed at the oldest purchase prices. You list your purchase lots in date order, let MIN and MAX work out how many units each lot supplies, and SUMPRODUCT turns that into the cost of goods sold. This guide is for small business owners, bookkeeping students and anyone asked to build a FIFO sheet in a job test.

The figures below are examples to show the method. How you must value stock for your accounts or taxes depends on your country's rules, so check with an accountant before you rely on a method for reporting.

What FIFO inventory means#

FIFO is a rule for deciding which purchase price applies to the units you sold. Prices change over time, so the same product can cost 4.00 in January and 5.00 in March. FIFO says the units sold first come from the oldest lot.

Three terms come up again and again:

TermMeaning
Lot (or layer)One purchase: a quantity bought at one unit cost
Cost of goods sold (COGS)What the units you sold cost you to buy
Ending inventoryThe cost of the units still on the shelf

Under FIFO, the units left at the end are always the newest ones, so ending inventory is valued at the latest prices.

Set up the purchase lots table#

Put one row per purchase, oldest at the top. The order matters: every formula below reads the table from top to bottom.

ABCD
1LotQtyUnit costUsed
2Jan1004.00
3Feb504.50
4Mar805.00

Put the total units sold for the period in G2: 170. You can type it, or add it up from a sales log with SUMIF, for example =SUMIF(Sales!B:B,"Mugs",Sales!C:C). The inventory tracker guide shows how to keep that log.

Doing it by hand first helps. The first 100 units come from January, the next 50 from February, and the last 20 from March. That's 100 + 50 + 20 = 170.

How many units each lot supplies: MIN and MAX#

One formula, filled down column D, does that split for you. In D2, type:

Excel formula
=MIN(B2,MAX(0,$G$2-SUM(B$1:B1)))

Fill it down to D4 (Windows: Ctrl+D; Mac: ⌘D). Read it from the inside out:

  1. SUM(B$1:B1) adds the quantities of all the lots above this one. In row 2 that range holds only the header, so the result is 0. In row 4 it becomes SUM(B$1:B3) = 150.
  2. $G$2-SUM(...) is how many units are still left to cost after the earlier lots: 170 in row 2, 70 in row 3, 20 in row 4.
  3. MAX(0, ...) stops the number going negative once the sales are used up.
  4. MIN(B2, ...) caps it at the lot size, because a lot can't supply more units than it holds.
LotQtyUnits beforeUsed
Jan1000100
Feb5010050
Mar8015020

The $ signs are what make the fill work. $G$2 stays fixed on the units sold. B$1 keeps the start of the range on row 1, while the end moves down one row at a time. The MIN function guide explains how MIN picks the smaller of two values.

Cost of goods sold with SUMPRODUCT#

SUMPRODUCT multiplies two ranges row by row and adds the results, which is exactly the FIFO cost of goods sold. In G3:

Excel formula
=SUMPRODUCT(C2:C4,D2:D4)

It works out 4.00 × 100 + 4.50 × 50 + 5.00 × 20 = 400 + 225 + 100 = 725. Both ranges must be the same size, or you get #VALUE!. The SUMPRODUCT function guide and the longer guide to SUMPRODUCT cover the details.

The average FIFO cost per unit sold is =G3/G2, which gives about 4.26. For more on per-unit costs, see how to calculate cost per unit.

Ending inventory value#

Ending inventory is the total cost of everything you bought, minus the cost of what you sold:

Excel formula
=SUMPRODUCT(B2:B4,C2:C4)-G3

Total purchases are 400 + 225 + 400 = 1,025, so ending inventory is 1,025 − 725 = 300. Check it: 60 units are left, all from the March lot at 5.00, and 60 × 5.00 = 300. When the check matches, your formulas are right.

You can also add a "Left" column with =B2-D2 to see the units remaining in each lot: 0, 0 and 60.

FIFO vs weighted average cost#

Weighted average cost uses one price for every unit: total cost divided by total units. Here that's 1,025 ÷ 230 = about 4.46 per unit, so 170 units sold cost about 757.61.

MethodCOGS for 170 unitsEnding inventory (60 units)
FIFO725.00300.00
Weighted average757.61267.39

When purchase prices rise, FIFO gives a lower cost of goods sold and a higher stock value, because the cheap old units are sold first. When prices fall, the opposite happens. The weighted average guide shows the SUMPRODUCT ÷ SUM formula, and the profit and loss statement guide shows where cost of goods sold goes in a report.

Keep the FIFO sheet working each month#

A FIFO table stays accurate if you follow a few rules:

  • Add new lots at the bottom. The formulas assume date order. Inserting a lot out of order costs sales at the wrong price.
  • Use cumulative sales. G2 should hold all units sold since the oldest lot still listed, not just this month's sales. To report one month, work out COGS for sales to date and subtract last month's figure. A running total column makes this easy.
  • Watch for overselling. If G2 is bigger than the total of column B, the sheet costs only the units you have. Add a check: =IF(G2>SUM(B2:B4),"Sold more than bought","OK").
  • Keep one table per product. FIFO is tracked item by item. A product code column and SUMIF can pull each product's sales into its own table.
  • Round at the end. Keep full unit costs in column C and round only the final totals.

Practise it#

The FIFO sheet is mostly careful sums and one SUMPRODUCT, so the core skills are adding up the right rows and locking the right references. Practise a department budget in a live spreadsheet to drill totals and $ references, then practise SUMIF to pull units sold per product from a sales log. Each lesson checks your formula instantly. Then try the exercise on this page to cost the 170 units yourself.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Column D already shows how many units each lot supplies to the 170 units sold. In G3, use SUMPRODUCT to work out the FIFO cost of goods sold from the unit costs (C2:C4) and the units used (D2:D4).

fx
ABCDEFGH
1
Lot
Qty
Unit cost
Used
2
Jan
100
4
100
Units sold
170
3
Feb
50
4.5
50
FIFO COGS
4
Mar
80
5
20
5
6
7

Tip: SUMPRODUCT takes two ranges of the same size, multiplies them row by row and adds the results.

Practise this in a lesson

LessonPractice: department budgetCombine SUM, AVERAGE, ROUND and absolute references in a realistic budget sheet.LessonSUMIFAdd up only the numbers that meet a condition, with and without a separate sum range.Function guideMINUse Excel's MIN to find the lowest price or shortest time, and to cap a value at a limit. Examples, common mistakes and a live exercise.Function guideSUMPRODUCTMultiply columns and add the results in one step with SUMPRODUCT. Totals, weighted averages, conditions, and a live exercise to try.

Frequently asked questions

How do you calculate FIFO in Excel?

+

List purchase lots oldest first with quantity and unit cost. For each lot, units used = MIN(lot quantity, MAX(0, units sold minus units in earlier lots)). Then SUMPRODUCT of unit costs and units used gives the cost of goods sold.

What is the FIFO formula for cost of goods sold?

+

Cost of goods sold is the sum of units taken from each lot times that lot's unit cost, starting with the oldest lot. In Excel that is =SUMPRODUCT(unit_cost_range, units_used_range) once you have a units-used column.

How do I calculate ending inventory with FIFO?

+

Subtract cost of goods sold from the total cost of all purchases. Under FIFO the units left over are the newest ones, so ending inventory is valued at the most recent prices.

What is the difference between FIFO and weighted average cost?

+

FIFO costs sales at the oldest prices first. Weighted average cost uses one average price for every unit: total cost divided by total units. When prices rise, FIFO gives a lower cost of goods sold than the weighted average.

Can Excel do FIFO automatically?

+

Excel has no built-in FIFO function, but a lot table with MIN, MAX and SUMPRODUCT formulas recalculates by itself whenever you change the units sold or add a new lot.

Sources

  • SUMPRODUCT function - Microsoft Support
  • MIN function - Microsoft Support
  • MAX function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What FIFO inventory means
  2. Set up the purchase lots table
  3. How many units each lot supplies: MIN and MAX
  4. Cost of goods sold with SUMPRODUCT
  5. Ending inventory value
  6. FIFO vs weighted average cost
  7. Keep the FIFO sheet working each month
  8. Practise it

Keep reading

Projects· 7 min read

Make an Inventory Tracker in Excel

To make an inventory tracker in Excel, keep two tables: a product list with each item's opening stock and reorder level, and a log with one row for every delivery or sale. SUMIF adds the stock in and out for each product, so current stock is opening plus in minus out. An IF formula and conditional formatting flag items to reorder.

Math· 7 min read

How to Calculate Cost per Unit in Excel

To calculate cost per unit in Excel, divide the total cost by the number of units: =B2/C2. Add every cost before dividing, such as =(B2+C2)/D2 for purchase plus shipping. Wrap it in ROUND for clean prices, =ROUND((B2+C2)/D2,2), and use IFERROR or IF to avoid #DIV/0! when units are zero.

Math· 6 min read

How to Make a Running Total in Excel

To make a running total in Excel, type =SUM($B$2:B2) in the first row next to your numbers and fill it down. The dollar signs lock the start of the range at B2, while the end moves down one row at a time, so each row adds everything from the top to itself. The last row equals the grand total.

More on projects

  • How to Build a Simple Three-Statement Financial Model in Excel
  • How to Make a GPA Calculator in Excel
  • Build a Gradebook in Excel
  • Build a Habit Tracker in Excel With Checkmarks and Streaks
  • Create an Invoice in Excel With Formulas
  • How to Build an Issue Log in Excel With Status and Aging
All projects articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free