To calculate ending inventory, take your beginning inventory, add net purchases for the period, and subtract the cost of goods sold: Beginning Inventory + Net Purchases โ COGS = Ending Inventory. The number that comes out depends heavily on the valuation method you use to assign costs to the units that left your shelves versus the ones still on them. Learning how to calculate ending inventory is really about learning that method choice, because the math around it is simple arithmetic.
The Formula and Its Inputs
Every ending inventory calculation runs on the same equation:
Beginning Inventory + Net Purchases โ Cost of Goods Sold = Ending Inventory
Beginning inventory is last period’s ending inventory carried forward. Net purchases include everything you bought during the period, plus freight-in costs, minus returns and allowances. Cost of goods sold is the dollar value assigned to the units that were sold, and that figure comes from your cost flow assumption.
The same equation rearranged gives you the more familiar COGS formula: Beginning Inventory + Net Purchases โ Ending Inventory = COGS. Which variable you solve for depends on whether you track inventory continuously or count it at period end. If you count units on the shelf and price them, you solve for ending inventory directly and COGS falls out as the residual. If your system logs each sale as it happens, COGS accumulates in real time and ending inventory is what remains.
Choosing a Valuation Method
When you buy the same product at different prices over a period, you need a rule for deciding which costs attach to units sold and which attach to units still on hand. The IRS permits several methods, and the one you choose must conform to best accounting practice in your industry and clearly reflect income.1eCFR. 26 CFR 1.471-2 – Valuation of Inventories
First-In, First-Out (FIFO)
FIFO assumes the oldest units are sold first, so ending inventory reflects the cost of your most recent purchases. When prices are rising, FIFO produces the highest ending inventory value and the lowest COGS. Most businesses default to FIFO because it mirrors how goods actually move through a warehouse.
Last-In, First-Out (LIFO)
LIFO assumes the newest units are sold first. Ending inventory carries the oldest purchase prices, which during inflation means a lower balance sheet figure and higher COGS. That higher COGS reduces taxable income, which is the main reason businesses choose LIFO.
The trade-off is a strict conformity requirement. If you use LIFO for your tax return, you must also use it in financial statements sent to shareholders, creditors, and other outside parties. Violating this rule can result in the IRS forcing you off LIFO entirely.2Internal Revenue Service. LIFO Conformity Requirement LIFO is also prohibited under International Financial Reporting Standards, so it may not be available if your business reports internationally.
Weighted Average Cost
This method divides the total cost of all goods available for sale by the total number of units available, then applies that single average cost to both units sold and units remaining. The resulting ending inventory always falls between what FIFO and LIFO would produce.
Specific Identification
Specific identification tracks the actual cost of each individual item. When you sell a unit, you charge its exact purchase cost to COGS, and each remaining item carries its own historical cost into ending inventory. This works well for vehicles, jewelry, or custom machinery, but it becomes impractical for thousands of identical units.
A Worked Example
Suppose you buy 10 units in January at $1 each, 10 more in April at $2 each, and 10 more in July at $3 each. You sell 15 units during the year, leaving 15 on hand. Here is what each method produces:
- FIFO: the 15 sold units come from the oldest stock first (all 10 at $1 plus 5 at $2, giving $20 in COGS). The 15 remaining units are the 5 newest $2 units and all 10 of the $3 units, giving ending inventory of $40.
- LIFO: the 15 sold units come from the newest stock first (all 10 at $3 plus 5 at $2, giving $40 in COGS). The 15 remaining units are the 10 oldest $1 units and 5 of the $2 units, giving ending inventory of $20.
- Weighted average: average cost per unit is $2 ($60 total cost รท 30 units). COGS for 15 units is $30, and ending inventory for 15 units is also $30.
Same purchases, same sales, but ending inventory ranges from $20 to $40 depending on the method. That $20 swing flows straight through to reported profit.
What to Include in the Count
Ending inventory should only include goods your business actually owns at the end of the period. Two situations trip people up.
Goods in Transit
Whether goods traveling between a seller and buyer belong in your inventory depends on the shipping terms. Under FOB shipping point terms, ownership transfers to the buyer the moment the goods leave the seller’s dock, so if you are the buyer and goods are still on a truck at period end, they belong in your count. Under FOB destination terms, the seller keeps ownership until the goods arrive, so in-transit goods stay in the seller’s inventory.
If you are closing the books on December 31 and a shipment left your supplier on December 29 with FOB shipping point terms, those goods are yours even though they have not arrived.
Consignment Goods
When a supplier places goods with a retailer on consignment, the supplier keeps ownership until the retailer sells the item to an end customer. The retailer should not include consignment goods in its ending inventory, and the supplier should not remove them from its own balance sheet until a sale occurs.
Reconciling to the Physical Count
No tracking system stays perfectly aligned with reality. Theft, damage, miscounts, and data entry errors create discrepancies that only a physical count can catch. When the count does not match the books, you adjust the records to match the floor. The difference is inventory shrinkage, and it gets recorded as a cost. For damaged or obsolete goods still physically on hand, the adjustment is a write-down rather than a write-off.
Lower of Cost or Net Realizable Value
Under GAAP, inventory measured using FIFO or average cost must be reported at the lower of its recorded cost or its net realizable value (NRV), which is the estimated selling price minus costs to complete and sell the item. If market conditions or physical deterioration push NRV below what you paid, you write the inventory value down and recognize the loss immediately. LIFO-based inventory follows a slightly different version of this rule and is excluded from the NRV simplification.3FASB. Accounting Standards Update 2015-11, Inventory (Topic 330)
The IRS takes a similar approach for tax purposes. Goods unsalable at normal prices because of damage, style changes, or broken lots must be valued at their actual selling price minus disposal costs.1eCFR. 26 CFR 1.471-2 – Valuation of Inventories You cannot carry inventory at inflated values just because that is what you originally paid.
Costs the IRS Requires You to Include
Section 263A of the Internal Revenue Code requires businesses that produce goods or acquire them for resale to capitalize both direct costs and a proper share of indirect costs into inventory.4Office of the Law Revision Counsel. 26 USC 263A – Capitalization and Inclusion in Inventory Costs of Certain Expenses Direct costs are materials and labor that go into creating or acquiring the product. Indirect costs are where businesses get tripped up: a share of rent, utilities, storage, and other overhead allocable to production or purchasing activity. Leaving required indirect costs out understates ending inventory and overstates your current-year deductions, which is the kind of thing that triggers adjustments on audit.
Small businesses with average annual gross receipts of $25 million or less (adjusted annually for inflation) are generally exempt from the Section 263A capitalization rules.5Federal Register. 1eCFR. 26 CFR 1.471-2 – Valuation of Inventories Switching between FIFO, LIFO, weighted average, or specific identification requires IRS approval through Form 3115, Application for Change in Accounting Method.6Internal Revenue Service. Instructions for Form 3115 You cannot simply start using a different method on next year’s return. This consistency rule is by design: it prevents businesses from cherry-picking methods year to year to minimize taxes.
The practical takeaway when you sit down to calculate ending inventory: confirm the method already in use, apply it to the units on hand at period end, include the freight and overhead the tax code requires, exclude anything you do not actually own, and adjust downward when market value has fallen below cost. The formula is one line. The judgment sits inside it.