Ending inventory formula: how to calculate ending and beginning inventory, with a calculator
Ending inventory = beginning inventory + purchases − cost of goods sold. Example: $12,000 + $31,500 − $28,500 = $15,000. Worked backward, beginning inventory = ending inventory + cost of goods sold − purchases. Purchases means the cost of goods purchased: what you paid, plus freight-in, less returns and discounts. Ending inventory becomes next period's beginning inventory. In Shopify, the Month-end inventory value report gives an ending figure, valued at each variant's current Cost per item.
Ending inventory calculator
Fill in three boxes and leave one empty: the empty one is worked out.
The formulas
Ending inventory = Beginning inventory + Cost of goods purchased − Cost of goods sold
Beginning inventory = Ending inventory + Cost of goods sold − Cost of goods purchased
Cost of goods purchased = Purchases + Freight-in − Returns, allowances and discounts
They are the same equation as the cost of goods sold calculation on Schedule C, lines 35 to 42, read in another order: inventory at the beginning of the year plus purchases and other costs gives goods available for sale, and inventory at the end of the year is what is left after cost of goods sold. Your ending inventory usually becomes next year's beginning inventory (IRS Publication 334).
A worked example
| Line | Amount |
|---|---|
| Beginning inventory | $12,000.00 |
| + Purchases, at the prices paid | $30,000.00 |
| + Freight-in | $1,500.00 |
| = Cost of goods purchased | $31,500.00 |
| = Goods available for sale | $43,500.00 |
| − Cost of goods sold | $28,500.00 |
| = Ending inventory | $15,000.00 |
Backward: $15,000 + $28,500 − $31,500 = $12,000, the beginning inventory.
FIFO or average cost changes the answer
Ending inventory depends on which cost the units still on the shelf carry. Take 40 units bought at $6.00, then 60 at $7.50, and 30 sold:
| Method | Cost of the 30 sold | Ending inventory, 70 units |
|---|---|---|
| FIFO: the oldest units leave first | $180.00 | $510.00 |
| Weighted average: $6.90 a unit | $207.00 | $483.00 |
FIFO: 30 × $6.00 sold, leaving 10 × $6.00 + 60 × $7.50. Average: (40 × $6.00 + 60 × $7.50) ÷ 100 = $6.90. FIFO and weighted average are both accepted under IFRS (IAS 2). More in FIFO vs weighted average for Shopify.
Finding the numbers in Shopify
| Number | Where | Watch |
|---|---|---|
| Ending inventory | Analytics > Reports > Month-end inventory value, range ending on the period's last day | Values every unit at today's Cost per item; counts On hand units since 1 October 2026 |
| Beginning inventory | Last period's ending figure, kept from your last close | Rerunning an old month reprices it at today's Cost per item |
| Cost of goods purchased | Supplier bills, received purchase orders, freight bills | Not in Shopify's reports as one figure |
| Cost of goods sold | Profit reports: the Cost column | Only variants that had a cost when they sold |
The catch: Month-end inventory value multiplies each variant's On hand units by its Cost per item (Shopify Help), and that is today's cost, even for a past month. On our demo store on 6 November 2026, July's ending value for one product was 69 units × $16.39, its cost now, although its average at the end of July was $15.71. Keep each month's ending figure when you close it.
How True COGS fits
- Records the price paid on every received purchase order or transfer, with its date, and keeps a weighted average, or FIFO cost on paid plans.
- Month-end close, on paid plans: opening inventory, purchases, revaluations, cost of goods sold and closing inventory for the month, recorded only when opening + purchases + revaluations − cost of goods sold equals closing to the cent.
- Each closed month keeps its own figures, so next month's beginning inventory is this month's ending one, not a figure repriced later.
Related guides
Questions merchants ask
What is the formula for ending inventory?
Ending inventory = beginning inventory + purchases − cost of goods sold. With $12,000 at the start, $31,500 of purchases and $28,500 of cost of goods sold, ending inventory is $15,000.
How do you calculate beginning inventory?
Beginning inventory is last period's ending inventory. If you don't have it, work it backward: ending inventory + cost of goods sold − purchases.
What is the cost of goods purchased?
What you paid for stock in the period, plus freight-in and other costs to bring it in, less purchase returns, allowances and discounts. It is the purchases line in the ending inventory formula.
Is ending inventory an asset?
Yes. Inventory you still hold at the end of the period is an asset on the balance sheet. When it sells, its cost becomes cost of goods sold.
Does Shopify calculate ending inventory?
Shopify's Month-end inventory value report multiplies each variant's On hand quantity at the end of the period by its current Cost per item. It does not use the beginning inventory + purchases − cost of goods sold formula.
Why does my ending inventory not match a stock count?
Lost, stolen, damaged or miscounted stock. The formula gives what you should hold; a count gives what you do hold. The difference is shrinkage, and it ends up in cost of goods sold.
Try True COGS free. True COGS is an inventory costing app for Shopify by Nexus Logic Systems. It records the price you paid on every delivery (a received purchase order or a transfer), with its share of freight and duty on paid plans, keeps every price with its date, and writes your moving weighted average cost, or FIFO cost on a paid plan, to Shopify's Cost per item. It is free for up to 25 variants with a cost on record; paid plans start at $29 a month or $290 a year.
Install from the App Store