How the Cost of Goods Sold Calculator works
Cost of Goods Sold (COGS) is the direct cost of the inventory a business actually sold during a period — the raw materials, merchandise, and direct production costs, but not overhead like rent or marketing. It is the figure subtracted from revenue on an income statement to get gross profit, so getting it right matters for pricing, tax reporting, and margin analysis.
The formula
This calculator uses the standard periodic-inventory formula:
COGS = Beginning Inventory + Purchases − Ending Inventory
Beginning inventory is the value of unsold stock on hand at the start of the period. Purchases is everything added to inventory during the period — merchandise or raw materials bought, freight-in, and direct production costs — net of any purchase returns, allowances, or discounts. Ending inventory is the value of unsold stock left at the close of the period. The logic is simple: whatever you started with plus whatever you added, minus whatever is left over, must be what you sold.
Worked example
A retailer starts the quarter with $50,000 of inventory, purchases $120,000 of additional merchandise, and ends the quarter with $35,000 still on the shelves. COGS = $50,000 + $120,000 − $35,000 = $135,000. If net sales for the quarter were $250,000, gross profit is $250,000 − $135,000 = $115,000, and gross margin is $115,000 / $250,000 × 100 = 46.0%.
Gross profit and gross margin
Once COGS is known, two related figures follow directly: Gross Profit = Net Sales − COGS, and Gross Margin (%) = Gross Profit ÷ Net Sales × 100. Gross margin shows what share of each sales dollar remains after covering the direct cost of the goods themselves, before operating expenses, interest, and taxes are subtracted. The calculator also reports the COGS ratio (COGS ÷ Net Sales × 100), the mirror image of gross margin, which is useful for tracking how the direct cost of goods trends as a share of revenue over time.
What moves COGS
- Ending inventory: a lower ending inventory (more sold through, or less carried over) raises COGS for the period, all else equal.
- Purchases: the more inventory added during the period, the higher goods available for sale — and, if it isn't left unsold, the higher COGS.
- Inventory valuation method: businesses that use FIFO, LIFO, or weighted-average costing can get different beginning and ending inventory values from the same physical stock, which changes COGS even when nothing else about the period differs.
Scope and assumptions
This calculator uses the periodic method common in general financial reporting and assumes the beginning inventory, purchases, and ending inventory figures you enter are already valued consistently (same costing method, same units). It does not separate cost of goods manufactured versus cost of goods purchased, and it is a computational tool, not tax or accounting advice — for GAAP, IFRS, or tax-specific inventory treatment, confirm the figures with an accountant.