Calculate your cost of goods sold
The calculator gives cost of goods sold, gross profit, gross margin and days inventory outstanding for a month, a quarter or a year. Days inventory outstanding is how many days, on average, goods stay in inventory before they are sold: average inventory ÷ COGS × 365, or 2,040 ÷ 14,500 × 365 ≈ 51 days for the example company. Enter inventory at cost at the start and end of the period, purchases for the same period and, to see the margin, net revenue.
A reseller leaves the labor and production field at 0. Amounts are in thousands of euros (€k), excluding sales tax or VAT; any currency works the same way. The default values are those of a fictitious distribution company.
Of €16,600k of goods available for sale, €2,100k is still on the shelves: the other €14,500k went out with the sales and is the period’s COGS. It absorbs 61.7% of revenue and leaves €9,000k of gross profit, a gross margin of 38.3%.
What is cost of goods sold (COGS)?
Cost of goods sold is the cost, at purchase or production price, of the goods it sold during the period. Goods bought but still in inventory are not part of it: they remain an asset until they are sold.
The idea fits in one rule: costs follow the goods. IAS 2, the international standard on inventories, says it in its own words. When inventories are sold, their carrying amount “shall be recognised as an expense in the period in which the related revenue is recognised.”
A typical scenario: a business owner reads their bank statement for March, sees €1,200k paid to suppliers and concludes that goods cost €1,200k that month. But part of what was paid restocked the warehouse, and part of what was sold came from stock bought in February. COGS sorts this out.
The company in our example is fictitious; its figures are the calculator’s default values. A midsize distributor starts the year with €1,980k of inventory and buys €14,620k of goods, excluding sales tax or VAT. It ends the year with €2,100k of inventory and €23,500k of net revenue.
COGS, cost of sales, cost of revenue
The same line has several names. US retailers and distributors say cost of goods sold; companies reporting under IFRS usually say cost of sales; software and service businesses say cost of revenue or cost of services. The calculation behind each name is the one below.
How do you calculate cost of goods sold?
The COGS formula is beginning inventory plus purchases minus ending inventory. For a manufacturer, purchases are replaced by the cost of goods manufactured in the period; both formulas need inventory valued at cost.
Goods available for sale
= beginning inventory
+ net purchases
+ freight-in and duties
+ production costs
COGS = goods available
− ending inventory
Gross profit = net revenue
− COGS
Gross margin = gross profit
÷ net revenueThis is the periodic method: you count what is left and deduce what went out. The Internal Revenue Service (IRS), the US tax authority, asks sole proprietors for exactly this sequence in Part III of Schedule C, lines 35 to 42:
| Schedule C line | What it holds | Example company (illustration) |
|---|---|---|
| 35 | Inventory at beginning of year | €1,980k |
| 36 | Purchases less cost of items withdrawn for personal use | €14,620k |
| 37 | Cost of labor (not paid to yourself) | €0 |
| 38 | Materials and supplies | €0 |
| 39 | Other costs | €0 |
| 40 | Add lines 35 through 39 | €16,600k |
| 41 | Inventory at end of year | €2,100k |
| 42 | Cost of goods sold: line 40 minus line 41 | €14,500k |
Lines 37 to 39 are where a manufacturer puts its production costs; a reseller leaves them empty. On a real Schedule C, amounts are in dollars.
A worked example: the distributor’s year
With the calculator’s default values:
Goods available
= 1,980 beginning inventory
+ 14,620 purchases
+ 0 freight-in + 0 production
= €16,600k
COGS = 16,600 − 2,100 ending
= €14,500k
Gross profit = 23,500 − 14,500
= €9,000k
Gross margin = 9,000 ÷ 23,500
= 38.3%
COGS ÷ revenue = 61.7%Two bars to scale show where the €16,600k of goods available ended up.
The company bought €14,620k but expensed only €14,500k: the €120k difference is the inventory build-up, from €1,980k to €2,100k. It is cash spent that will become cost next year, when those goods are sold.
The formula for a manufacturer
A manufacturer adds one step. It first calculates the cost of goods manufactured (COGM), the production cost of the units finished in the period, then applies the same formula to its finished goods inventory. Take a fictitious workshop, in €k:
Production costs
= 1,200 materials used
+ 800 direct labor
+ 600 production overhead
= 2,600
COGM = 150 work in progress
at start + 2,600
− 170 work in progress at end
= 2,580
COGS = 400 finished goods
at start + 2,580
− 380 finished goods at end
= 2,600Materials used are themselves purchases adjusted for the change in raw materials inventory. Our cost price calculator shows how production overhead is allocated to each product.
What is included in cost of goods sold?
COGS includes everything it took to get the goods into salable condition and location: purchase price net of discounts, inbound freight, import duties, non-recoverable taxes and, for a manufacturer, direct labor and production overhead. Selling and administrative costs stay out.
IAS 2 draws the line in two paragraphs. Under paragraph 11, the costs of purchase “comprise the purchase price, import duties and other taxes (other than those subsequently recoverable by the entity from the taxing authorities)”. Transport, handling and other costs directly attributable to the acquisition are added, and trade discounts and rebates are deducted. Paragraph 16 then lists what must be excluded.
| Cost | In COGS? | Why |
|---|---|---|
| Purchase price, net of trade discounts and rebates | Yes | Cost of purchase (IAS 2.11) |
| Freight-in, handling, import duties | Yes | Directly attributable to the acquisition |
| Sales tax collected, recoverable VAT | No | Not a cost: passed on or recovered |
| Direct labor and production overhead | Yes, for a manufacturer | Costs of conversion (IAS 2.12) |
| Abnormal waste of materials or labor | No, expensed directly | Excluded from inventory (IAS 2.16) |
| Storage after purchase | No, unless needed in production | Excluded (IAS 2.16) |
| Freight-out, sales commissions, advertising | No | Selling costs (IAS 2.16) |
| Office rent, management salaries | No | Administrative overhead (IAS 2.16) |
For a reseller, the usual trap is freight. Freight-in raises the cost of the goods; freight-out is a selling expense. Mixing the two moves gross margin without changing net income.
What about a service company?
A service company has no goods, but it has direct costs: the hours of the consultants billed, subcontractors, hosting for a software product. These form its cost of sales or cost of services. Whatever the name, the rule stays the same: only costs tied to what was delivered in the period.
Where does COGS go on the income statement?
COGS is the first expense on the income statement, right below net revenue; revenue minus COGS gives gross profit. Operating expenses (selling, general and administrative) come next and are deducted from gross profit to reach operating income.
The waterfall of the example company’s year:
Most US companies present their income statement this way. Some companies instead show expenses by nature: purchases, change in inventory, staff costs. Then there is no COGS line, and you rebuild it from purchases and the change in inventory.
COGS vs. operating expenses
The difference matters for decisions. COGS moves with volume: sell 10% more goods, and it rises by about 10%. Most operating expenses do not, at least in the short term. Our break-even calculator builds on this split between variable and fixed costs.
Gross margin and markup are two readings of the same gross profit: 9,000 ÷ 23,500 = 38.3% of revenue, or 9,000 ÷ 14,500 = 62.1% of cost. Our margin calculator converts one into the other and sets a selling price.
How do FIFO, LIFO and average cost change COGS?
When purchase prices change, the method used to value inventory decides which costs go into COGS and which stay in stock. FIFO, weighted average cost and LIFO give three different gross profits on the same goods and the same sales.
Take one item, in euros (not thousands): 100 units bought at €10, then 100 at €12, so €2,200 of goods available. The company sells 150 units.
- FIFO (first in, first out) charges the oldest units first: 100 × €10 + 50 × €12 = €1,600 of COGS, €600 left in stock.
- Weighted average cost charges every unit at €2,200 ÷ 200 = €11: 150 × €11 = €1,650, €550 in stock.
- LIFO (last in, first out) charges the newest units first: 100 × €12 + 50 × €10 = €1,700, €500 in stock.
The methods do not change the cash spent, only when it becomes an expense. Over the life of the stock, all three expense the same €2,200.
Which methods are allowed?
IAS 2 requires specific identification for items that are not interchangeable and, for the others, permits only FIFO or weighted average cost (§23 and §25): LIFO is not among them. US tax law allows LIFO. A company that uses LIFO for its federal tax return must also use it in the financial reports it gives shareholders and creditors. This is the LIFO conformity rule of section 472(c) of the Internal Revenue Code. It elects LIFO by filing Form 970.
Whatever the method, keep it from one year to the next. Switching changes COGS without any change in the business, and changing an accounting method for tax purposes requires the IRS’s consent (Pub 538).
How do you record cost of goods sold?
Under a perpetual system, each sale moves the cost of the goods from inventory to COGS as it happens. Under a periodic system, purchases are booked as they arrive and COGS is calculated at the end of the period from a stock count.
In a perpetual system, the ERP (the company’s management software) records two entries for each sale: debit accounts receivable and credit revenue; debit COGS and credit inventory. COGS is known every day, at the cost the system holds for each item.
In a periodic system, the books show purchases during the period. At the period-end close, the change in inventory adjusts them: ending inventory goes into the balance sheet and beginning inventory comes out. Purchases plus the decrease in inventory, or minus its increase, equal COGS. That is the calculator’s method.
Even a perpetual system needs a physical count. Theft, breakage and data-entry errors make the book inventory drift from what is on the shelves, a gap called shrinkage. The count corrects the inventory, and the difference goes into COGS.
What is a good COGS percentage of revenue?
No standard sets a good COGS ratio: it depends on the industry and on what the company adds to the goods it sells. Public gross margin statistics give the order of magnitude, and your own month-to-month trend says more than any average.
Aswath Damodaran, a finance professor at NYU Stern, publishes the gross margin of US listed companies by industry each January. COGS as a share of revenue is 100% minus that gross margin:
| Industry (US listed companies) | Firms | Gross margin | COGS % of revenue |
|---|---|---|---|
| Retail (grocery and food) | 15 | 26.3% | 73.7% |
| Retail (automotive) | 34 | 22.0% | 78.0% |
| Retail (distributors) | 62 | 30.6% | 69.4% |
| Retail (general) | 23 | 33.2% | 66.8% |
| Restaurants | 64 | 32.2% | 67.8% |
| Food processing | 78 | 23.2% | 76.8% |
| Machinery | 105 | 37.5% | 62.5% |
| Apparel | 35 | 56.9% | 43.1% |
| Software | 309 | 71.7% | 28.3% |
| All industries except financials | 4,822 | 34.4% | 65.6% |
These are listed companies, and each one draws the line between COGS and operating expenses its own way: read them as orders of magnitude, not targets. For retailers, the US Census Bureau’s Annual Retail Trade Survey publishes gross margin as a percentage of sales by type of store.
The example company, at 61.7% of revenue and a 38.3% gross margin, is a distributor: the closest row is Retail (distributors), at a 30.6% gross margin, and wholesalers in its own line are a better comparison than stores. A ratio that drifts by one or two points from month to month is the signal to watch: on €23,500k of revenue, one point of gross margin is worth €235k a year.
Which mistakes distort cost of goods sold?
Most COGS errors come from inventory, not purchases: ending inventory counted too high or too low moves gross profit by exactly the same amount. Cutoff errors, mixed freight and inconsistent valuation methods come next.
The effect of a count error of €100k on the example company:
- Treating purchases as COGS. Without the change in inventory, the example company would have shown €14,620k instead of €14,500k: a gross margin of 37.8% instead of 38.3%.
- Poor cutoff. Goods received on December 31 but invoiced in January are in the count without being in purchases: COGS falls. The reverse happens with goods invoiced before they arrive.
- Inventory at selling price. Inventory is valued at cost. Counting it at selling price inflates ending inventory by the margin and shrinks COGS.
- Obsolete inventory left at cost. Under IAS 2, inventory is carried at the lower of cost and net realizable value (the expected selling price minus the costs to finish and sell it); for US tax, Pub 538 allows the lower of cost or market. A write-down for goods that will no longer sell at cost goes into the period’s expenses.
- Different methods in different months. Average cost in one ERP, FIFO in a spreadsheet: margins become impossible to compare.
How do you track COGS every month in Power BI?
Monthly COGS needs a monthly inventory value: either a perpetual system that values stock at every movement, or a month-end count. With that, a Power BI report gives COGS and gross margin by month, product line and customer.
In Power BI, the calculation fits in a few measures written in DAX, Power BI’s formula language. Inventory is a balance: it is read at a date, not added up over a period. With a purchases table, an inventory snapshot table by month-end and a date table:
Purchases =
SUM ( Purchases[Amount] )
Ending inventory =
CALCULATE (
SUM ( Stock[Value] ),
LASTDATE ( 'Date'[Date] )
)
Beginning inventory =
CALCULATE (
[Ending inventory],
PREVIOUSDAY (
FIRSTDATE ( 'Date'[Date] )
)
)
COGS =
VAR BI = [Beginning inventory]
VAR EI = [Ending inventory]
RETURN
IF (
NOT ISBLANK ( BI )
&& NOT ISBLANK ( EI ),
BI + [Purchases] - EI
)The beginning inventory measure reads the day before the period starts: the previous month-end, for a month, a quarter or a year. When either inventory is missing, such as the month after the last loaded count or the current year, the COGS measure stays blank instead of counting the whole inventory as consumed. If your ERP posts COGS on each sale, use that table directly: it is more precise and gives COGS by product.
The most useful views are the gross margin by month against budget, by product line, and the gap between book inventory and the count. Our guide to the financial dashboard shows where these sit among the finance KPIs, and the inventory turnover calculator uses the same COGS to measure how long goods stay in stock.
Frequently asked questions
Is COGS an expense?
Yes. Cost of goods sold is an expense, recognized in the same period as the revenue from the goods it relates to. It is not an operating expense in the usual sense: it sits above gross profit, while selling, general and administrative expenses sit below it. Until the goods are sold, the same cost is an asset, inventory, on the balance sheet.
Is COGS the same as cost of sales?
Mostly. Companies that sell goods say cost of goods sold; IFRS financial statements and many service companies say cost of sales; software and service businesses often say cost of revenue. All three name the direct cost of what was sold in the period, the figure subtracted from revenue to get gross profit.
Does COGS include shipping?
Freight-in, the cost of bringing goods to your warehouse, is part of their purchase cost and therefore of COGS once they are sold. Freight-out, the cost of delivering to customers, is a selling expense under IAS 2, which excludes selling costs from inventory. Companies classify outbound shipping differently: check the accounting policy note.
Can COGS be negative?
No. A negative result means the inputs are wrong: usually ending inventory counted too high, purchases posted to the wrong period, or inventory counted at selling price. COGS can be very low for a service company or a month with almost no sales, but it can never fall below zero. The calculator flags the case.
Does COGS include labor?
Only the labor that makes the goods. A manufacturer’s direct labor and production overhead are costs of conversion under IAS 2 and go into inventory, then into COGS when the goods are sold. Schedule C line 37 asks for the cost of labor, not including amounts paid to yourself. Sales and office staff stay out of COGS.
