COGS calculator

This COGS calculator works out cost of goods sold as opening inventory plus purchases, plus carriage inwards, less returns outwards, less closing inventory. It sets the figures out as a trading account, then takes them on to gross profit, gross margin, markup, inventory days and inventory turnover, with each line of the working printed beneath.

Switching currency changes formatting only. Amounts are not converted.

$
$0$10,000,000,000

Last period's closing inventory, at cost.

$
$0$10,000,000,000

Goods bought for resale in the period, net of sales tax you can reclaim.

$
$0$10,000,000,000

Delivery costs paid to bring goods in. Delivery to customers is not included.

$
$0$10,000,000,000

$
$0$10,000,000,000

Goods still on hand at the end of the period, at cost.

$
$0$10,000,000,000

Sales returns and the inventory days basis
$
$0$10,000,000,000

Show the working

The trading account is where bookkeeping reaches gross profit

Opening inventory, purchases and the closing count come together in the trading account. The ACCA KL Financial Accounting-FA Online Course for Exam Preparation covers double-entry bookkeeping, financial statements, inventory, accruals and accounting standards basics.

See the course

These are financial calculators made to make calculations easier and to help you find answers. They work only on the numbers you enter.

Worked example. A business that starts with 40,000 dollars of inventory, buys 250,000 dollars of goods, pays 5,000 dollars of carriage inwards, returns 3,000 dollars of goods to suppliers and ends with 50,000 dollars of inventory has a cost of goods sold of 242,000 dollars. On sales of 400,000 dollars that leaves gross profit of 158,000 dollars, a gross margin of 39.5%, and the average inventory of 45,000 dollars is about 67.9 days of cost of goods sold.

Why the inventory count matters

What the closing inventory count does to profit

Your trading account with only closing inventory changed: every extra unit counted moves out of cost of goods sold and into gross profit.

Trading account

The inner column builds cost of goods sold; the outer column carries sales, cost of goods sold and gross profit, as a written answer sets them out.

How do you calculate cost of goods sold?

Start with what you had, add what you bought, and take away what is left: cost of goods sold = opening inventory + purchases + carriage inwards - returns outwards - closing inventory. Purchases, carriage inwards and returns outwards together are net purchases. Opening inventory plus net purchases is the cost of all the goods the business could have sold in the period; whatever is still on the shelves at the end was not sold, so its cost comes off.

The calculator opens on a business with $40,000 of opening inventory. It buys $250,000 of goods, pays $5,000 to have them delivered and sends $3,000 back to suppliers, so net purchases are $252,000 and goods available for sale are $292,000. The year-end count finds $50,000 still in stock, which makes cost of goods sold $292,000 - $50,000 = $242,000. Against sales of $400,000 that is 60.5% of revenue, the COGS percentage, and it leaves gross profit of $158,000.

Worked example: a trading account set out for an exam

A trading account shows the same sum in two columns: the inner one builds cost of goods sold, the outer one carries the totals. Here is a business reporting in pounds, with sales of £152,000 and £3,000 of goods returned by customers:

Trading account££
Sales152,000
Less returns inwards(3,000)
Net sales149,000
Opening inventory18,500
Purchases96,400
Add carriage inwards1,200
Less returns outwards(2,100)
Goods available for sale114,000
Less closing inventory(21,300)
Cost of goods sold(92,700)
Gross profit56,300

Gross profit of £56,300 on net sales of £149,000 is a gross margin of 37.79%. Average inventory is (£18,500 + £21,300) / 2 = £19,900, which covers 78.4 days of cost of goods sold. Enter these figures with the currency set to GBP, and put the returns inwards under Sales returns, to see the same layout under the result.

What counts as purchases, carriage and returns?

  • Purchases are goods bought to sell on, or materials for the goods you make. Equipment, rent and wages for the sales team are expenses or assets, not purchases.
  • Carriage inwards is the cost of getting goods in. IAS 2, the IFRS standard on inventories, includes in cost all costs of purchase and of conversion, plus other costs of bringing inventories to their present location and condition, which is why delivery inwards belongs in cost of goods sold.
  • Carriage outwards, delivering goods to customers, is a selling cost. It goes below gross profit, not into the trading account.
  • Returns outwards are goods sent back to suppliers, so they reduce purchases.
  • Returns inwards are goods customers send back, so they reduce sales, not cost of goods sold.
  • Sales tax or VAT that the business can reclaim is left out of purchases, just as tax charged to customers is left out of sales.

A manufacturer adds a further layer: its cost of goods sold also carries production labor and factory overheads, the costs of conversion, which this calculator expects you to include in purchases if you want them in the answer.

How does closing inventory change cost of goods sold and profit?

One for one, in opposite directions. Closing inventory is subtracted, so every extra dollar counted lowers cost of goods sold by a dollar and raises gross profit by the same dollar. On the default figures, a count of $60,000 instead of $50,000 cuts cost of goods sold to $232,000 and lifts gross profit to $168,000, taking the gross margin from 39.5% to 42%. With no closing inventory at all, cost of goods sold would be the full $292,000 and gross profit $108,000. The second chart under the result plots that straight-line trade for your own figures.

That is why the year-end count is checked so carefully. An error also flows into the next year, because this year's closing inventory is next year's opening inventory. Overstate the count by $10,000 and this year's gross profit is $10,000 too high; next year's opening inventory is then $10,000 too high, its cost of goods sold $10,000 too high and its gross profit $10,000 too low. Over the two years the total is right, but each year's figure is wrong.

Trading accounts, inventory valuation and cost of sales are part of financial accounting study for the ACCA exams. See the ACCA KL Financial Accounting-FA Online Course for Exam Preparation.

FIFO or weighted average: how does the cost formula change COGS?

The count tells you how many units are left; a cost formula decides what each one cost. The IFRS Foundation's summary of IAS 2 says inventories are measured at the lower of cost and net realizable value. It assigns cost by specific identification for items that are not ordinarily interchangeable, and by first-in, first-out (FIFO) or weighted average cost for items that are. Take a product line that opens with 100 units at $10, buys 200 at $12 and then 100 at $13, and sells 300 units at $20 each at the end of the period:

Cost formulaCost of goods soldClosing inventoryGross profit on $6,000 of sales
FIFO: oldest units sold first100 x $10 + 200 x $12 = $3,400100 x $13 = $1,300$2,600
Weighted average: $4,700 / 400 units = $11.75 each300 x $11.75 = $3,525100 x $11.75 = $1,175$2,475

The goods available cost $4,700 either way; the formulas only split it differently between cost of goods sold and closing inventory. With prices rising through the period, FIFO leaves the newest, dearest units in inventory, so it shows the lower cost of goods sold and the higher profit, here by $125. Work out closing inventory under the formula you use, then enter it in the calculator.

How do you get gross profit, gross margin and markup from COGS?

Gross profit is net sales less cost of goods sold. Divide it by net sales for the gross margin and by cost of goods sold for the markup. On the default figures, $158,000 / $400,000 = 39.5% margin and $158,000 / $242,000 = 65.29% markup: the same profit, measured against a different base. COGS as a share of sales is the other half of the margin, 60.5% here, since the two always add up to 100% of net sales.

A worked example in dirhams: a retailer opens the year with AED 120,000 of inventory, buys AED 860,000 of goods and ends with AED 140,000. Cost of goods sold is AED 120,000 + AED 860,000 - AED 140,000 = AED 840,000. On sales of AED 1,350,000, gross profit is AED 510,000, a gross margin of 37.78% and a markup of 60.71%. For margins further down the income statement, the profit margin calculator takes cost of goods sold as its cost of sales line.

How do you calculate inventory days and inventory turnover?

Both compare inventory with cost of goods sold, because inventory is held at cost. Inventory days = inventory / cost of goods sold x 365 says how long the goods sit before they are sold. Inventory turnover = cost of goods sold / inventory says how many times the stock is sold and replaced in a year. The two are reciprocals: 365 divided by one gives the other.

ExampleInventory usedInventory daysTurnover
Default, average inventory$45,00067.95.38 times
Default, closing inventory$50,00075.44.84 times
AED retailer, average inventoryAED 130,00056.56.46 times

Average inventory smooths out a year-end that is unusually high or low; closing inventory is the figure a single balance sheet gives you. Choose the basis under Inventory days based on, and keep it the same when you compare periods. Inventory days feed straight into the cash conversion cycle, which the working capital calculator builds.

How do you calculate COGS in Excel or Google Sheets?

Lay the trading account down one column. With opening inventory in B1, purchases in B2, carriage inwards in B3, returns outwards in B4 and closing inventory in B5:

  • Cost of goods sold: =B1+B2+B3-B4-B5, which returns 242000 for the default figures.
  • With sales in B6 and the COGS formula in B7, gross margin: =(B6-B7)/B6, which returns 39.5% when formatted as a percentage.
  • COGS percentage: =B7/B6, which returns 60.5%.
  • Inventory days on average inventory: =AVERAGE(B1,B5)/B7*365, which returns about 67.87.

Google Sheets accepts the same formulas. For a reusable template, keep the inputs in one block and the formulas in another, and link next period's opening inventory to this period's closing cell so the two can never disagree.

Common cost of goods sold mistakes

  • Adding closing inventory instead of subtracting it. Closing inventory is what was not sold.
  • Putting carriage outwards in cost of goods sold. Delivery to customers is a selling expense.
  • Taking returns inwards off purchases. They reduce sales; returns outwards reduce purchases.
  • Valuing inventory at selling price. Inventory is held at cost, or at net realizable value when that is lower.
  • Using sales instead of cost of goods sold for inventory days. Inventory is at cost, so the ratio needs a cost figure too.
  • Breaking the link between periods. This year's opening inventory has to equal last year's closing figure.
  • Confusing margin with markup. A 39.5% margin and a 65.29% markup describe the same default gross profit.

What the COGS calculator leaves out, and a glossary

It works one period at a time from totals you supply. It does not cost individual units, apply a cost formula, count inventory or test it against net realizable value, and it treats every purchase figure as already net of reclaimable sales tax. A manufacturer's labor and overheads go in only if you add them to purchases. For the quantity to order rather than the cost of what was sold, see the EOQ calculator.

Cost of goods sold (COGS): the cost of the inventory sold in the period, also called cost of sales. Inventory: goods held for sale, at cost or net realizable value if lower. Net purchases: purchases plus carriage inwards less returns outwards. Goods available for sale: opening inventory plus net purchases. Gross profit: net sales less cost of goods sold. Net realizable value: estimated selling price less the costs of completing and selling. Trading account: the part of the income statement that runs from sales to gross profit.

Frequently asked questions

What is the formula for cost of goods sold?

Cost of goods sold = opening inventory + purchases + carriage inwards - returns outwards - closing inventory. With $40,000 opening, $250,000 of purchases, $5,000 carriage, $3,000 of returns and $50,000 closing, it is $242,000.

How do you calculate COGS without opening inventory?

For a business in its first period, opening inventory is zero, so cost of goods sold is net purchases less closing inventory. In every later period, opening inventory is the previous period's closing figure and must be included.

Is cost of goods sold the same as cost of sales?

For a trading business they are two names for the same figure: the cost of the goods sold in the period. This page uses cost of goods sold throughout, and the arithmetic is identical whichever name a set of accounts prints.

Does carriage inwards go into cost of goods sold?

Yes. The cost of bringing goods to where they are sold is part of their cost, so it is added to purchases. Carriage outwards, the cost of delivering to customers, is a selling expense and goes below gross profit.

How does closing inventory affect gross profit?

Closing inventory is subtracted to find cost of goods sold, so a higher closing figure means lower cost of goods sold and higher gross profit, by exactly the same amount. Raising the default count from $50,000 to $60,000 lifts gross profit from $158,000 to $168,000.

What is the COGS percentage?

Cost of goods sold divided by net sales. On the defaults it is $242,000 / $400,000 = 60.5%. It and the gross margin always add up to 100% of net sales.

Which cost formulas does IAS 2 allow?

According to the IFRS Foundation's summary of IAS 2, items that are not ordinarily interchangeable are costed by specific identification, and interchangeable items by first-in, first-out or weighted average cost. Inventories are then measured at the lower of cost and net realizable value.

How do you calculate inventory days?

Divide inventory by cost of goods sold and multiply by 365. Average inventory of $45,000 against cost of goods sold of $242,000 is about 67.9 days. Using closing inventory of $50,000 instead gives about 75.4 days.

Where do returns inwards and returns outwards go?

Returns inwards are goods customers bring back, so they come off sales. Returns outwards are goods sent back to suppliers, so they come off purchases. Neither is added to cost of goods sold.

Can I work in pounds, euros or dirhams?

Yes. Pick the currency above the inputs and the trading account is shown in it, with no conversion of the figures you type. Margins, inventory days and turnover come out identical in any currency.

Courses related to inventory and cost of sales

ACCA KL Financial Accounting-FA Online Course for Exam Preparation

Exam-focused preparation for the ACCA Financial Accounting paper, covering double-entry bookkeeping, financial statements, inventory, accruals, and accounting standards basics.

See what the course covers

ACCA SL Financial Reporting-FR Online Course for Exam Preparation

Exam-focused preparation for the ACCA Financial Reporting paper, covering IFRS, consolidation, revenue recognition, leases, financial instruments, and statement interpretation.

See what the course covers

ACCA KL Management Accounting-MA Online Course for Exam Preparation

Exam-focused preparation for the ACCA Management Accounting paper, covering costing, budgeting, variance analysis, performance measurement, and investment appraisal techniques.

See what the course covers

Sources and review

Last reviewed 13 November 2026 by the NIFM Academy editorial team. Next review by 13 November 2027.

  • IFRS Foundation, IAS 2 Inventories (ifrs.org standard page), inventories are measured at the lower of cost and net realisable value; cost includes all costs of purchase, costs of conversion and other costs of bringing inventories to their present location and condition; specific identification for items not ordinarily interchangeable, FIFO or weighted average for items that are. Checked 13 November 2026.
  • Cost of goods sold arithmetic, opening inventory plus net purchases less closing inventory, gross profit, margin, markup, inventory days and turnover, reproduced in the working under every result. Checked 13 November 2026.

About these calculators. These are financial calculators made to make calculations easier and to help you find answers. Every result is arithmetic on the figures you enter. It is not a forecast, and it is not a recommendation to buy, sell or hold any security, currency, fund or product. NIFM Academy is an online education provider.

Amounts are shown in the currency you choose and are never converted between currencies. Any rate, allowance or tax figure the page fills in is dated where it appears, and you can change it.