ClearStock is live on the Shopify App Store.Install free →

← All blogs

Guides8 min read

Beginning and ending inventory: the equation your COGS depends on

Beginning and ending inventory: the equation behind COGS, where each input lives in a Shopify store, and how counting errors propagate for two quarters.

InventoryX is in development and not available today. ClearStock is the live Shopify app.

Your beginning and ending inventory aren't two numbers to look up at period ends. They're one number, handed forward: this quarter's ending becomes next quarter's beginning, unchanged. Both feed the same equation that produces COGS — so a miscount never corrupts just one period. It corrupts two, in opposite directions, and each corrupted period is one where you made pricing, reorder, and ad-spend calls on a margin that wasn't real.

Here is the identity, where each input lives in a Shopify store as of October 2026, a worked quarter showing how an illustrative $4,500 miscount propagates, and the counting habit that keeps the chain honest.

One equation, two directions

Ending inventory = beginning inventory + purchases − COGS

COGS = beginning inventory + purchases − ending inventory

Same equation, rearranged. Two ways to read it; merchants almost always live in the first:

  • Count the ending, and COGS falls out. You know what you started with, what you received, and you count what's left — the cost of what sold is whatever's missing. At period close, this is how COGS gets computed.
  • Know COGS, and the ending falls out. Rearranged, the equation becomes a sanity check: if your books say COGS was $48,500, the shelf count should support an ending value that closes the identity. When it doesn't close, one of the three inputs is lying.

A vocabulary note: beginning and ending inventory here mean dollar values at cost at the period boundary — December 31, not "whenever I got around to counting." How those dollars get assigned to units (FIFO, weighted average, retail method) is a separate decision; the inventory valuation methods guide owns it.

Where each input comes from in a Shopify store

As of October 2026, the three inputs map to three artifacts:

Input Source What makes it honest
Beginning inventory The prior period's ending — carried forward, never re-derived The prior period ended with a count
Purchases Goods received into inventory during the period — PO + receiving records Receive-before-shelving; in-transit goods don't count yet
Ending inventory The counted, adjusted inventory at period end Counted near the boundary; every location included

On purchases: the equation wants goods received, not ordered or paid for. A container on the water on March 31 is not in Q1's purchases — it enters when it's received into Shopify inventory. If deposits and balances land in different periods, cash dates and goods dates diverge; that gap is its own topic.

On ending inventory: Shopify computes inventory value at each location as cost per item × sellable quantity (Shopify Help Center, accessed October 2026). Two implications. Count discipline is everything — quantities are only as good as your last count plus whatever drifted since. And cost-field hygiene matters: a variant with an empty or stale cost per item contributes $0 or a wrong value to the ending total, and no count fixes a wrong cost. How Shopify turns those costs into COGS order by order is the territory of the Shopify COGS guide; this article stays at the period boundary.

Why errors propagate instead of washing out

An ending-inventory error doesn't stay in its own period. Walk the mechanism:

  • Ending understated (the count found less than reality): this period's COGS is overstated — the books think you sold more than you did — and next period's beginning is understated by the same amount, so next period's COGS is understated and its margin looks flattered. The error lands twice.
  • Ending overstated (phantom stock — a receipt keyed twice, units sold but never decremented): the reverse. This period's COGS is understated and margin flattered; next period begins too high, and its margin is punished.

Either way the errors cancel in total — but only if the second period ends with a clean count, which is a choice, not a guarantee. In the meantime you carry two quarters of wrong margins and a balance-sheet inventory asset that stays wrong until a count catches it. The cancellation is cold comfort: nobody makes decisions on two-period totals.

A worked quarter, then the miscount

Illustrative numbers throughout; a stationery brand selling notebooks and pens.

The honest quarter. Beginning inventory (December 31 count): $38,000. Purchases received January–March: $52,000. Counted ending (March 31): $41,500.

COGS = $38,000 + $52,000 − $41,500 = $48,500

Against Q1 revenue of $97,000, gross margin is $48,500 — exactly 50%.

The miscount variant. Same quarter, same shelves, same sales — except the March 31 count records $46,000, because a February receipt was keyed into Shopify twice, adding $4,500 of stock that does not exist.

Recorded COGS = $38,000 + $52,000 − $46,000 = $44,000

Recorded margin: $53,000 on $97,000, or 54.6% — overstated by exactly the $4,500 of phantom stock. Nothing physical changed; the Q1 report says the business got 4.6 points more profitable, and the only error was a keystroke.

Q2, where the error lands the second time. April 1 begins at the recorded $46,000 — $4,500 high, because beginning inventory is never re-derived. Say Q2 purchases are $55,000 and the June 30 count is honest at $49,800:

Recorded True (had Q1 ended at $41,500)
Q2 beginning $46,000 $41,500
Q2 purchases $55,000 $55,000
Q2 ending (counted) $49,800 $49,800
Q2 COGS $51,200 $46,700

Q2's recorded COGS runs $4,500 heavier than reality, so Q2's margin comes in $4,500 worse. Now the two quarters together:

Recorded True
Q1 COGS $44,000 $48,500
Q2 COGS $51,200 $46,700
Six-month COGS $95,200 $95,200

The error cancelled itself — because Q2 ended with a clean count. Six-month totals agree; neither quarter is right. A Q1 decision ("margins improved — raise ad spend") or a Q2 decision ("margins slipped — tighten reorders") was made on a number that was never true. One double-keyed receipt, two quarters of wrong decisions — and the self-correction only happened because the June count was clean.

The reconciliation habit

The fix isn't more spreadsheet columns; it's a cadence that keeps the ending number honest:

  • Cycle counts on a schedule. A-items monthly, B-items quarterly, C-items twice a year — the cadence, plus the close-of-day rule that prevents mid-day overwrites, is in the Shopify inventory counts guide. A handful of counted SKUs a week keeps the ending value weeks-fresh where it matters most.
  • Reconcile, don't just adjust. When a count disagrees with the admin, apply the correction and find the cause — tying Shopify's numbers to the shelves and to the books is the stock reconciliation process. An adjustment with no cause is a discrepancy scheduled to recur.
  • Run a monthly mini-close. Pull beginning (last month's ending), purchases (the month's receipts), and an ending count of your fast movers; full-count the rest quarterly or annually. Ten minutes confirming the three inputs agree beats a quarterly surprise.
  • Maintain cost fields. New variants get a cost per item the day they're created; supplier price changes get updated at the next PO. A count certifies quantities; only your cost fields can certify values.

Where average inventory fits

Ratios like inventory turnover and days of inventory on hand use average inventory, (beginning + ending) ÷ 2, rather than either endpoint — it smooths the sawtooth between the pre-restock low and the post-receipt high. Two cautions. An average built on two wrong numbers inherits both errors, so count discipline comes first (the average inventory guide covers the calculations). And stretching the counting interval makes the average worse: a March 31 count averaged against a September 30 count says little about June.

Common questions

What is the formula for ending inventory? Ending inventory = beginning inventory + purchases − COGS. Run the other way, COGS = beginning + purchases − ending — the same equation, which is why an ending-inventory error flows straight into COGS. Purchases means goods received during the period; goods still in transit at the boundary date belong to the next period.

Where does beginning inventory come from? From the prior period's ending inventory, carried forward unchanged — never re-derived. This is why ending counts matter twice: the number certifies this period's COGS and becomes next period's starting point. A period that ends without a count passes whatever drift has accumulated forward as fact.

What happens if ending inventory is wrong? An understated ending overstates this period's COGS and understates next period's beginning — which understates next period's COGS. An overstated ending does the reverse. The errors cancel in total only if the next period ends with a clean count; until then, each quarter runs on a wrong margin.

Does Shopify calculate inventory value for me? Yes — Shopify computes inventory value at each location as cost per item × sellable quantity (Shopify Help Center, accessed October 2026). Two things matter: counted-accurate quantities and maintained cost fields. A variant with an empty or stale cost contributes a wrong dollar value no amount of counting can fix.

How often should I count to keep ending inventory honest? Cycle counts beat annual marathons: A-items monthly, B-items quarterly, C-items twice yearly, with a full stock take yearly to reset the baseline. Count after close of day, never mid-day — mid-day counts overwrite the units that sold while you counted.

Next step

Run this month's mini-close: pull last month's ending value, this month's receipts, and count your ten fastest SKUs after close this week. Confirm the identity closes within rounding. If the count and the admin disagree by more than pocket change, fix it and find the cause before filing anything — the margin report you were about to trust depends on the ending number. No period closes on an uncounted guess.