Use this LIFO inventory calculator to estimate cost of goods sold (COGS), remaining inventory value, revenue, gross profit, and gross margin. The last-in, first-out method assigns the newest purchase costs to the units sold first, leaving older costs in ending inventory.
LIFO is a cost-flow assumption, not a requirement to ship your newest goods first. Your warehouse can rotate physical stock differently from the way you assign costs for accounting.

How to use the LIFO calculator
- Enter purchases from oldest to newest. The 1st purchase is your oldest inventory layer; the last purchase entered is the newest. The calculator supports up to five purchase layers.
- Enter the Purchase Price per unit. Use the unit cost, not the total cost of the batch. For example, a batch of 1,000 bricks costing $500 has a purchase price of $0.50 per brick.
- Enter Units Purchased for each layer. Use consistent units throughout, such as individual items, cases, or pounds. Do not mix cases purchased with individual items sold.
- Enter the Selling price per unit and Units Sold. The calculator uses one selling price for all units sold.
- Review the results together. COGS and remaining inventory split the purchase costs between sold and unsold units. Revenue, gross profit, and gross margin show the sales outcome.
Use the calculator for one product or a group of interchangeable units. Keep Units Sold at or below the total quantity available, and leave unused purchase layers at zero.
This is a simplified purchase-layer calculation. Because there are no transaction-date fields, it does not reconstruct a perpetual LIFO ledger with purchases and sales interspersed throughout a period. If opening inventory is relevant, include its cost layers among the purchases entered.
How to calculate LIFO inventory and COGS
Each purchase creates a cost layer: a quantity of units acquired at a particular unit cost. First, calculate the total cost available:
Total inventory cost = P1Q1 + P2Q2 + … + PnQn
Here, P is the purchase price per unit, Q is the quantity purchased, and n is the number of purchase layers.
To calculate LIFO COGS, allocate sold units to the newest layer first. Use only as many units as that layer contains, then move backward through older layers until every sold unit has a cost assigned.
COGS = Sum of (units allocated from each layer × that layer’s unit cost)
A sale can use part of a layer; you do not have to exhaust an entire purchase batch. Once COGS is known, the remaining calculations are:
- Remaining inventory value = Total inventory cost − COGS
- Total revenue = Selling price × Units sold
- Gross profit = Total revenue − COGS
- Gross margin = (Gross profit ÷ Total revenue) × 100%
Gross margin is undefined when revenue is zero. It is a percentage of revenue, not a markup percentage on cost.
Worked example: selling across several LIFO layers
A building supplier purchases four batches of the same brick, then sells 2,500 bricks at $1.20 each after all four purchases.
| Purchase order | Units purchased | Purchase price per brick | Batch cost |
|---|---|---|---|
| 1st: November 11 | 1,000 | $0.50 | $500 |
| 2nd: November 15 | 1,000 | $0.60 | $600 |
| 3rd: November 16 | 1,000 | $0.80 | $800 |
| 4th: November 22 | 1,000 | $0.90 | $900 |
Total inventory before the sale is 4,000 bricks costing $2,800. Under LIFO, the sale uses the two newest layers in full and 500 bricks from the second purchase:
COGS = (1,000 × $0.90) + (1,000 × $0.80) + (500 × $0.60) = $2,000
The remaining 1,500 bricks retain their older costs:
Remaining inventory value = (1,000 × $0.50) + (500 × $0.60) = $800
| Result | Calculation | Value |
|---|---|---|
| COGS | $900 + $800 + $300 | $2,000 |
| Remaining inventory value | $2,800 − $2,000 | $800 |
| Total revenue | 2,500 × $1.20 | $3,000 |
| Gross profit | $3,000 − $2,000 | $1,000 |
| Gross margin | ($1,000 ÷ $3,000) × 100% | 33.33% |
A useful check is that COGS plus remaining inventory equals the original inventory cost: $2,000 + $800 = $2,800.
What the results mean for your business
- COGS measures the assigned purchase cost of units sold. It is not the selling price or necessarily the amount paid to suppliers during the current period.
- Remaining inventory value is a carrying cost. It does not estimate resale value or the cost of replacing those goods today.
- Gross profit is not net profit. It excludes operating expenses, interest, and taxes. Costs omitted from your purchase-price inputs are also absent from the calculation.
- Gross margin depends on both selling price and cost layers. A change in margin may reflect which layers were used, rather than a change in purchasing efficiency.
For pricing decisions, compare LIFO gross profit with current replacement costs as well. If sales exhaust recent purchases and reach much older, cheaper layers, reported profit can rise without any improvement in selling prices. This effect is commonly called LIFO liquidation.
LIFO vs. FIFO: when does the choice matter?

FIFO, or first-in, first-out, assigns the oldest purchase costs to sales first. The difference between the methods depends on how purchase prices change.
| Purchase-cost trend | LIFO compared with FIFO |
|---|---|
| Rising costs | Generally higher COGS, lower gross profit, and lower ending inventory value |
| Falling costs | Generally lower COGS, higher gross profit, and higher ending inventory value |
| Identical costs across all layers | The same COGS and ending inventory value |
In the brick example, FIFO would produce COGS of $1,500 and ending inventory of $1,300. Revenue would remain $3,000, but gross profit would be $1,500 rather than $1,000. The accounting method changes cost allocation, not the proceeds from the sale.
LIFO can match recent purchase costs against current revenue, but it can leave inventory recorded at old costs. During rising prices, its higher COGS may reduce taxable income where LIFO is permitted; this is not a guaranteed tax saving.
U.S. GAAP permits LIFO, while IFRS does not. Choosing or changing an inventory method has accounting and tax implications, so confirm the applicable rules with your accountant. Physical stock rotation is a separate decision: perishable goods still need appropriate handling regardless of the accounting method.
Related inventory calculations
- Use the ending inventory calculator to work through the broader relationship between beginning inventory, purchases, and COGS.
- Use the inventory turnover calculator to assess how quickly inventory sells. Keep inventory valuation methods consistent when comparing periods.
Build a cost-comparison calculator for your customers
If your business helps customers evaluate purchasing costs, use Calcopolis to build a customized cost-and-savings calculator that compares current and proposed supplier prices at their expected order volumes.