Accounting
How To Calculate The Cost Of Goods Sold
Cost of goods sold is the direct cost of the inventory a business actually sold during a period. Under the periodic inventory method it is beginning inventory plus purchases minus ending inventory, which gives 55,000 in the worked case. This page is an educational heuristic, not investment advice.
Last updated
Quick Answer
Cost of goods sold = beginning inventory + purchases - ending inventory
- Beginning inventory
- Value of unsold stock carried into the period
- Purchases
- Cost of stock acquired or produced during the period
- Ending inventory
- Value of stock still on hand at the end of the period
- Revenue
- Sales recorded for the same period
- Cost of goods sold
- Direct cost attributed to the goods that were sold
Add purchases to the value of inventory on hand at the start of the period, then subtract the value still on hand at the end. With 20000 beginning, 50000 purchases and 15000 ending, cost of goods sold is 55000. On revenue of 100000 that leaves gross profit of 45000 and a gross margin of 0.45, or 45%; doubling purchases would raise cost of goods sold to 105000.
What Is The Cost Of Goods Sold?
Cost of goods sold, often shortened to COGS, is the direct cost of the goods a business sold during a period. It appears near the top of the income statement, immediately below revenue, and it captures materials, direct labour and production overhead tied to what left the business. In the worked case the figure is 55,000, arrived at by combining an opening stock of 20,000 with 50,000 of purchases and a closing stock of 15,000. The metric answers a narrow question: what did the items that generated sales actually cost to bring in or make? It is an educational heuristic and is not investment advice.
Only direct production costs belong in this figure. Raw materials, the wages of workers who assemble the product and factory overhead that varies with output are all included. Rent on the head office, sales salaries, marketing and administration are operating expenses that sit below the gross line and must be excluded. Pulling those costs into cost of goods sold would distort the measure and make any industry comparison meaningless. Keeping the boundary clean is the first discipline in using the number.
The periodic method builds the answer in three lines. Beginning inventory of 20,000 records the stock carried into the period at its accounting value. Adding purchases of 50,000 gives goods available for sale of 70,000. Ending inventory of 15,000 represents stock that was never sold and remains an asset on the balance sheet, so it is taken away. What is left, 55,000, is the cost attributed to the goods that did sell.
Subtracting ending inventory is the step people most often get wrong. Those unsold goods have not been consumed by sales, so their cost must be carried forward rather than charged against revenue. This creates a clear direction: a higher ending inventory lowers cost of goods sold, while a lower ending inventory raises it. In the worked case raising ending inventory from 15,000 to 25,000 would cut cost of goods sold to 45,000. The sign matters, because reversing it would produce a figure that moves opposite to the underlying business. A period of heavy buying that ends with a larger stockpile therefore reports a lower cost of goods sold, even though cash went out to acquire it.
The other two inputs push in the opposite direction. Raising beginning inventory or purchases increases the cost of goods available for sale and therefore increases cost of goods sold when ending inventory is unchanged. Doubling purchases from 50,000 to 100,000 while keeping the other inputs fixed takes cost of goods sold from 55,000 to 105,000. That sensitivity shows why purchasing decisions flow directly into the metric. It also shows why the figure can jump sharply in a period when a business buys ahead of demand.
Cost of goods sold matters chiefly because it determines gross profit. Revenue of 100,000 less cost of goods sold of 55,000 leaves gross profit of 45,000, the amount available to cover operating costs and contribute to profit. Dividing that gross profit by revenue gives a gross margin of 0.45, or 45%. This is a share of sales, not a markup on cost: the corresponding markup would divide 45,000 by 55,000 and give a different figure. Confusing the two is a common source of error in pricing conversations.
The calculation here is the periodic inventory method, which measures cost of goods sold at the end of the period from a single stock count. A perpetual system instead tracks each sale and each receipt continuously, updating the inventory balance as it goes. Both should agree when the records are sound, but timing differences and stock losses can make them diverge. Real accounts must also adjust for freight in, purchase discounts, returns and write-offs, none of which appear in this simplified expression. The method used should be consistent from period to period, because switching it changes the reported cost without any change in the underlying trade. A stock count taken at a busy seasonal peak will also differ from a quieter date, so the timing of the closing count deserves as much care as the arithmetic.
Businesses watch cost of goods sold because it is the lever that links purchasing, production and pricing. A rising ratio against revenue can mean input prices have climbed, that discounting has squeezed the price received, or that waste has increased on the production line. A falling ratio may signal better supplier terms or improved efficiency, and sometimes simply a change in product mix. The figure is normally read beside inventory turnover, which shows how quickly stock moves, and beside gross margin, which expresses the same relationship as a share of sales. No single period tells the whole story, so the trend usually carries more information than one reading.
Like any accounting measure, the result depends on definitions that vary between organisations. What counts as a purchase, how freight is allocated and which costs are treated as production overhead all shift the figure. Accrual accounting counts goods when invoiced rather than when paid, so cost of goods sold is not the same as cash spent on inventory in the period. Currency movements and changes to the product range can move it as well. Used carefully, and alongside the absolute values behind each input, it remains a clear view of direct production cost. This page offers an educational heuristic and is not investment advice.
Formula
COGS = beginning inventory + purchases - ending inventory
Formula page →Add purchases to opening stock to get goods available for sale, then subtract closing stock. 20,000 plus 50,000 gives 70,000; taking away 15,000 leaves 55,000.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| Beginning inventory | Value of stock carried into the period | currency | The worked value is 20,000 and is added. |
| Purchases | Cost of stock acquired or made during the period | currency | The worked value is 50,000 and is added. |
| Ending inventory | Value of stock still held at the end | currency | The worked value is 15,000 and is subtracted. |
Gross profit = revenue - cost of goods sold
Formula page →Revenue less the direct cost of what was sold. 100,000 of revenue minus 55,000 of cost of goods sold leaves 45,000 of gross profit.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| Revenue | Sales recorded for the period | currency | The worked value is 100,000. |
| Cost of goods sold | Direct cost of goods sold in the period | currency | The worked value is 55,000 and is subtracted. |
Gross margin = (revenue - cost of goods sold) / revenue
Formula page →Gross profit expressed as a share of revenue. 45,000 over 100,000 gives 0.45, or 45%. The interface stores this as a decimal.
| Symbol | Meaning | Unit | Notes |
|---|---|---|---|
| Revenue | Sales recorded for the period | currency | The denominator, 100,000 in the worked case. |
| Cost of goods sold | Direct cost of goods sold in the period | currency | The worked value is 55,000 and is subtracted from revenue. |
How To Calculate The Cost Of Goods Sold
- 1
Take beginning inventory
Start with the accounting value of stock the business carried into the period. In the worked case that is 20,000. Use the same valuation basis for every period, because changing the basis alters the figure without any change in the physical stock.
- 2
Add purchases made during the period
Add the cost of goods acquired or produced for sale, which is 50,000 here. This brings the running total to goods available for sale of 70,000. Keep freight, returns and discounts consistent with how the inventory values were set, since mixing treatments breaks the comparison.
- 3
Subtract ending inventory
Deduct the value of stock still on hand at the end, 15,000 in the worked case, because those goods were not sold and remain an asset. The running total falls from 70,000 to cost of goods sold of 55,000. Reversing this sign is the single most common mistake and would give a result that moves the wrong way.
- 4
Compute gross profit
Subtract cost of goods sold from revenue. Revenue of 100,000 less 55,000 leaves gross profit of 45,000. This is the amount available to cover operating expenses and contribute to profit, and it sits above all selling and administrative costs.
- 5
Compute gross margin and read the result in context
Divide gross profit of 45,000 by revenue of 100,000 to get a gross margin of 0.45, or 45%. Rising purchases would push cost of goods sold up and the margin down, while a higher ending inventory would do the opposite. This is the periodic method and an educational heuristic rather than investment advice; real accounts also adjust for freight, discounts and write-offs.
Examples
Example 1: Baseline — 20000 opening, 50000 purchases, 15000 closing
- beginningInventory
- 20000
- purchases
- 50000
- endingInventory
- 15000
- revenue
- 100000
| Step | Calculation | Result |
|---|---|---|
| State beginning inventory | 20000 | 20000 |
| Add purchases to get goods available | 20000 + 50000 | 70000 |
| Subtract ending inventory | 70000 - 15000 | 55000 |
Result: Beginning inventory 20000 plus purchases 50000 less ending inventory 15000 gives cost of goods sold of 55000, and on revenue of 100000 gross profit is 45000 and gross margin is 0.45, or 45%.
Example 2: Lower purchases — 30000 instead of 50000
- beginningInventory
- 20000
- purchases
- 30000
- endingInventory
- 15000
- revenue
- 100000
| Step | Calculation | Result |
|---|---|---|
| State beginning inventory | 20000 | 20000 |
| Add the smaller purchases figure | 20000 + 30000 | 50000 |
| Subtract ending inventory | 50000 - 15000 | 35000 |
Result: Cutting purchases to 30000 reduces goods available for sale to 50000, so with ending inventory still 15000 the cost of goods sold is 35000, and on revenue of 100000 gross profit rises to 65000.
Example 3: Higher closing stock — 25000 instead of 15000
- beginningInventory
- 20000
- purchases
- 50000
- endingInventory
- 25000
- revenue
- 100000
| Step | Calculation | Result |
|---|---|---|
| State beginning inventory | 20000 | 20000 |
| Add purchases to get goods available | 20000 + 50000 | 70000 |
| Subtract the larger ending inventory | 70000 - 25000 | 45000 |
Result: Raising ending inventory to 25000 leaves more stock on the balance sheet, so cost of goods sold falls to 45000, and on revenue of 100000 gross profit is 55000 and gross margin is 0.55, or 55%.
Calculator
Cost of goods sold
$55,000.00
- Gross profit
- $45,000.00
- Gross margin
- 45.00%
- Cost of goods sold at doubled purchases
- $105,000.00
Values update as you type. This calculator covers the single scenario its formula assumes — see Common Mistakes for what it leaves out.
Prefer a full-width tool? Open the The Cost Of Goods Sold calculator page.
Common Mistakes
Reversing the sign of ending inventory
Ending inventory is subtracted, not added, because those goods were never sold. Adding the 15000 would give 85000 instead of 55000 and would make the figure move opposite to the underlying business.
Including operating expenses in the cost of goods sold
Rent, sales salaries, marketing and administration are operating costs that sit below the gross line. Including them produces a figure that no industry comparison can use and understates gross profit.
Mixing periods for stock and purchases
Beginning stock, purchases and ending stock must all belong to the same period. Taking a closing count from one month and purchases from another breaks the identity and produces a number that matches nothing real.
Scaling the gross margin percentage twice
The calculator stores the margin as a decimal and the display layer renders it as a percentage. Multiplying the expression again by one hundred would show 4500% instead of 45%, a large and easily missed error.
Ignoring freight, discounts and write-offs
This simplified expression omits freight in, purchase discounts, returns and stock write-offs. For a real set of accounts those adjustments must be made before the figure can be relied upon.
Switching the inventory method without restating
Moving from periodic to perpetual accounting, or changing the valuation basis, changes the reported cost of goods sold even when the underlying trade is unchanged. Restate prior periods before drawing comparisons.
FAQ
What is the formula for cost of goods sold?
Under the periodic method it is beginning inventory plus purchases minus ending inventory. With 20000 opening, 50000 purchases and 15000 closing, the result is 55000.
Which costs belong in cost of goods sold?
Direct costs tied to production: materials, direct labour and manufacturing overhead that varies with output. It excludes rent, sales salaries, marketing and administration, which are operating expenses.
Why is ending inventory subtracted?
Because those goods were not sold and remain an asset on the balance sheet. Their cost must be carried forward rather than charged against revenue, so a higher ending inventory lowers cost of goods sold.
How does cost of goods sold differ from gross profit and gross margin?
Cost of goods sold is a cost in currency. Gross profit is revenue minus that cost, which is 45000 here. Gross margin is gross profit divided by revenue, which is 0.45, or 45%.
What happens when purchases double?
Cost of goods sold rises by the same amount when other inputs are fixed. Doubling purchases from 50000 to 100000 takes goods available for sale to 120000 and cost of goods sold to 105000.
Is this calculation investment advice?
No. It is an educational heuristic that explains how an accounting figure is built and interpreted. It should be read alongside the full financial statements before any business or investment decision, and it does not recommend any company or security.
References
- [1], Cost of goods sold — https://en.wikipedia.org/wiki/Cost_of_goods_sold
- [2], Inventory — https://en.wikipedia.org/wiki/Inventory
- [3], Gross profit — https://en.wikipedia.org/wiki/Gross_profit
