FIFO vs LIFO Inventory Cost Calculator

FIFO vs LIFO Inventory Cost Calculator

Growing AI Skill PRO

Enter Calculation

Formula

COGSFIFO=∑i=1ncimin⁡(qi,max⁡(0,Units sold−∑j<iqj))COGS_{FIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,\text{Units sold}-\sum_{j<i} q_j\right)\right)
Show calculation steps (2)
  1. LIFO cost of goods sold

    COGSLIFO=∑i=1ncimin⁡(qi,max⁡(0,Units sold−∑j>iqj))COGS_{LIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,\text{Units sold}-\sum_{j>i} q_j\right)\right)

    Lots are consumed in reverse purchase order until the units sold are covered.

  2. COGS difference

    Δ=COGSLIFO−COGSFIFOwhere COGSFIFO=∑i=1ncimin⁡(qi,max⁡(0,Units sold−∑j<iqj))qi,ci from Purchase lots\begin{gathered}\Delta = COGS_{LIFO}-COGS_{FIFO}\\ \text{where } COGS_{FIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,\text{Units sold}-\sum_{j<i} q_j\right)\right)\\ q_i,\,c_i \text{ from } \text{Purchase lots}\end{gathered}

    LIFO COGS minus FIFO COGS, computed from the purchase lots and units sold.

Usage stats

Advertisement

Results

COGS difference (LIFO − FIFO)
600.00
$
Item FIFO LIFO
Cost of goods sold 2,800.00 $ 3,400.00 $
Ending inventory 2,800.00 $ 2,200.00 $
Total units available 450 units
Units in ending inventory 200 units
Cost of goods available 5,600.00 $
Number of lots 3

Based on Publication 538 (01/2022), Accounting Periods and Methods (Effective from 2022-01)

Report an error on this page

What this calculator does

This calculator assigns inventory costs under two cost-flow assumptions, FIFO (first-in, first-out) and LIFO (last-in, first-out). Enter purchase lots and the number of units sold. It returns cost of goods sold (COGS) and ending inventory under each method, and the difference between them. It suits small business owners, bookkeepers and students comparing how the choice of method changes reported profit and stock value.

Two stacked columns of cost layers; the left removes from the bottom layer, the right removes from the top layer.
FIFO draws down the oldest cost layer first, while LIFO draws down the newest.

How to use it

First, fill in Purchase lots: one lot per line, oldest first, written as quantity, unit cost (for example 100, 10.50). Semicolons can also separate lots. Use a point for decimals and leave out thousands separators and currency symbols. Put opening inventory on the first line. Second, fill in Units sold: the total units sold or disposed of in the period. It must not exceed the total quantity of all lots.

Formula

For lots \(i = 1 \dots n\) with quantity \(q_i\) and unit cost \(c_i\), and units sold \(S\):

$$COGS_{FIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,S-\sum_{j<i} q_j\right)\right)$$

$$COGS_{LIFO}=\sum_{i=1}^{n} c_i\,\min\left(q_i,\max\left(0,\,S-\sum_{j>i} q_j\right)\right)$$

$$EI_m=\sum_{i=1}^{n} q_i c_i - COGS_m,\qquad \Delta = COGS_{LIFO}-COGS_{FIFO}$$

Here \(EI_m\) is ending inventory under method \(m\), and \(\Delta\) is the COGS difference. A positive \(\Delta\) means LIFO gives higher COGS.

Advertisement

Conventions and assumptions

  • FIFO: units sold come from the earliest lots first; ending inventory is the most recent purchases.
  • LIFO: units sold come from the latest lots first; ending inventory is the earliest lots.
  • Periodic layering: all lots are treated as on hand before the sale, with one total for units sold. Perpetual LIFO with interleaved sales can give different results.
  • Opening inventory: enter it as the first line at its carried cost.
  • Unit cost: used as entered. Enter invoice price minus trade discounts plus freight and other acquisition charges, as IRS Publication 538 (2022) describes purchase cost.
  • Unit LIFO only: a single item with specific-goods LIFO; dollar-value and index pools are not used.
  • Partial lots: a lot may be partly consumed, and quantities may be decimals.
  • Rounding: no intermediate rounding; currency shows 2 decimals.
  • Currency: amounts are in whatever currency the unit costs use.
  • Weighted-average cost is not included.

Worked example

Lots: 100 units at 10, 150 at 12, 200 at 14. Units sold: 250. Total units available are 450 and the cost of goods available is:

$$100\times 10 + 150\times 12 + 200\times 14 = 5600$$

FIFO takes 100 at 10 and 150 at 12:

$$COGS_{FIFO} = 1000 + 1800 = 2800,\quad EI_{FIFO} = 5600 - 2800 = 2800$$

LIFO takes 200 at 14 and 50 at 12:

$$COGS_{LIFO} = 2800 + 600 = 3400,\quad EI_{LIFO} = 5600 - 3400 = 2200$$

$$\Delta = 3400 - 2800 = 600$$

Ending inventory is 200 units under both methods.

How to read the result

When costs rose across the lots, LIFO reports higher COGS and lower ending inventory than FIFO, so the difference is positive. When costs fell, the difference is negative. If there is a single lot, all lots share one unit cost, nothing is sold, or everything is sold, the difference is zero. The method totals always satisfy COGS plus ending inventory equals cost of goods available. Limitations: the tool does not model perpetual LIFO, dollar-value LIFO, lower of cost or market adjustments, or weighted-average cost. Tax rules for adopting or changing a method are complex, so confirm with a qualified adviser or the IRS.

Advertisement
Two equal-height stacked bars whose split point between a lower and upper segment sits at different heights.
The same total purchase cost divides differently between COGS and ending inventory under each method.

FAQ

Why do FIFO and LIFO give different COGS?

They assume different units were sold. With changing prices, the lots consumed carry different unit costs, so COGS and ending inventory differ.

Can I enter opening inventory?

Yes. Put it on the first line at its carried cost so it counts as the oldest layer.

Why was my input refused?

Each line needs exactly two plain numbers. A value such as 1,000 is read as two numbers, so write 1000. Units sold also cannot exceed total quantity.

Does this include weighted-average cost?

No. The source used here covers FIFO and LIFO, so weighted-average is not offered.

Is LIFO accepted everywhere?

Rules vary by country and by reporting framework. This tool follows the IRS description and does not assert acceptance elsewhere.

Sources

Sources & References

  • Publication 538 (01/2022), Accounting Periods and Methods — Internal Revenue Service (US). Also defines LIFO (items purchased last are the first sold; closing inventory drawn in order of acquisition). It describes the direction of the FIFO/LIFO difference under rising and falling prices, and the components of purchase cost. · Effective from 2022-01 · Verified 2026-11-04
Last updated:

Most popular in Financial

View all Financial calculators