COGS formula: calculate cost of goods sold step by step
Learn the COGS formula with a worked example for tracked and periodic stock, plus a free worksheet.

Written by Lena Hanna—Trusted CPA Guidance on Accounting and Tax. Read Lena's full bio
Published Tuesday 6 October 2026
Table of contents
Key takeaways
- Use the retail COGS formula (opening stock + purchases − closing stock), or add up direct materials, direct labour and manufacturing overhead if you make your own goods
- Include only the direct costs of making or buying your products, such as raw materials and production wages, and treat rent, marketing and admin salaries as operating expenses
- Follow the worked example: an Irish retailer with €12,000 opening stock, €30,000 of purchases and €9,000 closing stock has COGS of €33,000 for the quarter
- Let tracked (perpetual) inventory post COGS as you sell, or count stock at period end and post a stock adjustment if you use untracked (periodic) inventory
What is COGS?
Cost of goods sold (COGS) is the direct cost to produce or purchase the goods you sell. Its calculation is governed by official accounting standards, such as when the International Accounting Standards Board adopted IAS 2 Inventories to provide guidance. COGS covers only the expenses tied directly to creating your products.
What to include in COGS
COGS includes costs directly tied to producing or purchasing the goods you sell:
- direct materials: raw materials and components used in production
- direct labour: wages for workers who make or assemble products
- manufacturing overheads: factory utilities, equipment maintenance, and production supplies
Depending on your business, you may also include:
- freight costs: shipping for incoming materials or outgoing products
- storage costs: warehousing and inventory holding expenses
- transaction fees: payment processing costs directly tied to sales
Some businesses, like ecommerce businesses, also include freight, storage, sales commissions, or transaction fees when these costs relate directly to selling products.
What not to include in COGS
COGS excludes indirect costs that support your business but aren’t tied to specific products:
- rent: office or retail space costs (unless exclusively for production)
- marketing and advertising: promotional expenses
- administrative salaries: wages for management, HR, or accounting staff
- general overhead: utilities for non-production spaces, office supplies
- sales team salaries: compensation for salespeople (though commissions may be included)
- depreciation: equipment depreciation is typically an operating expense
Salaries depend on the role. Wages for staff who make your products count as direct labour in COGS, while admin, management and sales salaries are operating expenses.
When in doubt, ask: “Does this cost exist only because I made or purchased this specific product?” If yes, it’s likely COGS. If no, it’s probably an operating expense, one of the indirect costs of running your business as a whole.
COGS formula
There are two main COGS formulas, one for retailers and one for manufacturers.
Retail COGS formula: Beginning inventory + Purchases − Ending inventory = COGS
Manufacturing COGS formula: Raw materials + Manufacturing costs + Storage costs + Freight = COGS
The formula you use depends on your business model. Here’s how each works.
The retail formula is simpler because it focuses on inventory values rather than production costs.
Retail COGS formula
If you run a retail or ecommerce business, you can calculate COGS by focusing on your inventory changes over a period.
Cost of goods sold formula used by retailers for inventory accounting.
(Beginning inventory + Purchases) − Ending inventory = COGS
How to calculate retail COGS:
- Find your beginning inventory: Record the total value of inventory at the start of your accounting period.
- Add purchases: Include all inventory costs acquired during the period.
- Subtract ending inventory: Deduct the value of inventory remaining at the end of the period.
The result is your COGS for that period.
This formula focuses on inventory values rather than sales numbers, which helps account for discarded or damaged stock.
Manufacturing COGS formula
Manufacturers have more complex supply chains. It makes sense for them to add up all the costs on their product’s journey to the customer.
If you manufacture your own goods, your formula adds up the direct costs of production.
Direct materials + Direct labour + Manufacturing overhead = COGS
Manufacturers have more complex supply chains. It makes sense for them to add up all the costs on their product’s journey to the customer. Be aware that some choose not to count warehousing or freight.
How to calculate manufacturing COGS:
- Calculate raw materials cost: Add up the direct materials used to produce goods.
- Add manufacturing costs: Include labour, energy, and other production expenses.
- Add storage costs: Factor in warehousing and inventory holding expenses.
- Add freight costs: Include shipping for incoming materials and outgoing deliveries.
The total gives you your manufacturing COGS. Some manufacturers choose not to include warehousing or freight, so check with your accountant for what applies to your business.
If you use accounting software like Xero, you can find COGS in the profit and loss (P&L)/income parts of your financial statements.
How to calculate COGS
Once you have the right formula, calculating your COGS is a straightforward process. Follow these steps to get an accurate figure.
How to calculate retail COGS
Retailers work from the value of stock on hand and the stock bought during the period. Use these four steps.
- Determine your starting inventory value. This is the total value of your inventory at the beginning of your accounting period. It should be the same as your ending inventory from the previous period.
- Add the cost of purchases. Tally up the cost of all inventory you purchased during the period. Include any costs like shipping or freight to get the items to you.
- Determine your ending inventory value. At the end of the period, calculate the total value of the inventory you still have on hand.
- Apply the formula. Add your beginning inventory to your purchases, then subtract your ending inventory. The result is your COGS for the period.
How to calculate manufacturing COGS
Manufacturers add up the direct costs of making their products. Use these four steps.
- Calculate the cost of direct materials. Add up the total cost of all raw materials used in production during the period.
- Calculate direct labour costs. Sum the wages and benefits paid to employees directly involved in manufacturing your products.
- Add manufacturing overhead. Include all other direct costs of production, such as factory rent, utilities, and equipment depreciation.
- Sum the totals. Add your direct materials, direct labour, and manufacturing overhead costs together to find your COGS.
Examples of COGS
Here’s a worked example for an Irish retailer over one quarter, using the retail COGS formula. Follow the five steps to see where each figure comes from.
- Find your opening stock, which is the same as your closing stock from the last period. The retailer ended last quarter with €12,000 of stock, so that’s the opening figure.
- Add your purchases of stock for resale during the quarter, including delivery costs to get the goods to you. The retailer bought €30,000 of stock, delivery included.
- Count your closing stock at the end of the quarter and value it at the lower of cost and net realisable value. Net realisable value is the expected selling price less the costs to sell, and the retailer’s count comes to €9,000.
- Apply the formula by adding opening stock and purchases, then subtracting closing stock. For the retailer, €12,000 + €30,000 − €9,000 = €33,000 COGS for the quarter.
- Check your gross profit by subtracting COGS from sales. With sales of €55,000, the retailer’s gross profit is €55,000 − €33,000 = €22,000, a 40% margin.
Manufacturers add up production costs instead. For example, a manufacturer spends €7,000 on raw materials, €3,000 on energy and labour, and €1,200 on shipping: €7,000 + €3,000 + €1,200 = €11,200 COGS.
How you record the retailer’s €33,000 depends on whether your software tracks stock with each sale or you count it at period end.
COGS with tracked (perpetual) inventory
With tracked inventory, also called perpetual inventory, COGS builds up with every sale you invoice. You can see the running total at any point in the quarter.
Each sale moves the item’s cost from the inventory asset account on your balance sheet to COGS as you invoice. In Xero, tracked inventory items post COGS automatically using the average cost method.
After a stocktake, the quarter’s COGS should match opening stock plus purchases minus closing stock, or €33,000 for the retailer. Any difference is a stock adjustment, such as shrinkage or damaged goods.
COGS with untracked (periodic) inventory
With untracked inventory, also called periodic inventory, you work out COGS at the end of each period. Your stock count does the work that tracking does in the perpetual method.
When you enter a supplier bill, the purchase goes straight to a purchases or cost of sales expense account. Nothing sits on your balance sheet until you count stock at the end of the period.
You then post a closing stock adjustment so COGS equals opening stock plus purchases minus closing stock. For the retailer, €30,000 of purchases is expensed as the bills come in. Stock falls from €12,000 to €9,000, so a €3,000 stock movement increases COGS to €33,000.
To run these numbers for your own business, download the COGS worksheet. It’s a spreadsheet that works out opening stock plus purchases minus closing stock, then checks your gross profit.
COGS and different business models
Your business model determines which costs count as COGS and which formula to use. Here’s how different businesses approach it:
- Manufacturers tend to include certain indirect costs like material handling
- Retailers typically calculate COGS using beginning and ending inventory values
- Service businesses often include direct labour costs as their primary COGS component
Why COGS is important for small businesses
COGS directly affects your profitability and pricing decisions. Knowing your true cost to serve customers helps you set competitive prices while maintaining healthy margins.
Materials and labour costs are typically straightforward to calculate. Other costs can be more challenging for new business owners.
For example, small business owners who use their home as a production facility may enjoy good margins initially. However, COGS will increase when they upgrade to dedicated manufacturing or warehousing premises.
Monitoring COGS helps you identify and address the factors that put pressure on your profit margins. Here’s how COGS supports better business decisions.
Pricing
COGS sets your pricing floor. It establishes the baseline cost you must exceed to make a profit. Understanding your COGS helps you judge how cost fluctuations affect expenses and when to adjust prices.
Profitability
Lower COGS means higher gross profit. Reducing your cost of goods sold while maintaining prices directly increases your gross profit margin. Even small COGS improvements can significantly affect your bottom line.
Inventory management
COGS analysis reveals inventory efficiency. Tracking your costs helps you identify slow-moving items and assess stock performance.
Use these insights to optimise stock levels, reorder points, and product mix. This balances demand while reducing capital tied up in unsold goods.
Taxes
COGS is a tax-deductible business expense. Tracking and documenting all COGS components helps you maximise deductions and prepare for audits, although some tax authorities provide exceptions to the rules for smaller businesses.
Check with your local tax authority for specific rules on COGS deductions in your region.
Strategic decision-making
COGS data supports smarter business decisions. Accurate cost tracking provides context for strategic financial analysis.
Use COGS insights to evaluate:
- investing in new product lines
- automating production processes
- changing distribution methods
COGS accounting methods
Your inventory valuation method directly affects your COGS calculation. Different methods assign different costs to sold items versus remaining inventory.
As you sell inventory, its value transfers from your balance sheet to your income statement as COGS. According to accounting standards, the inventory’s carrying amount becomes an expense in the same period that revenue is recognised. The method you choose determines which specific costs get assigned.
Different accounting methods suit different business types and economic conditions.
FIFO (first in, first out) method
FIFO (first in, first out) assumes the oldest inventory items sell first. This method often matches the physical flow of goods through your business.
When prices are rising, FIFO typically results in lower COGS and higher reported profits. It’s commonly used by businesses selling perishable goods or products with expiration dates.
LIFO (last in, first out) method
LIFO (last in, first out) assumes the most recently acquired inventory sells first. During inflation, LIFO typically results in higher COGS and lower reported profits.
Important: LIFO is not permitted under International Financial Reporting Standards (IFRS). The International Accounting Standards Board (IASB) prohibits LIFO because of its potential to misrepresent inventory flows, and it is disallowed in many countries outside the United States. Check whether LIFO is allowed in your region before using this method.
Average cost method
Average cost method uses the weighted average of all inventory costs to value both COGS and ending inventory. This approach smooths out price fluctuations over time.
The average cost method works well for businesses with large quantities of similar items where tracking individual costs isn’t practical.
Specific identification method
Specific identification method tracks the actual cost of each individual inventory item. This approach provides the most accurate COGS but requires detailed record-keeping.
Use this method for high-value or unique items like vehicles, artwork, or custom-built products. It’s impractical for businesses with large quantities of similar items.
Tips for managing and reducing COGS
Reducing COGS while maintaining quality can significantly improve your profit margins. Here are practical strategies to help you manage and lower your costs.
Negotiate with suppliers
Negotiate with suppliers regularly to secure better prices on materials and goods.
Consider these approaches:
- request volume discounts for bulk purchases
- negotiate long-term contracts for price stability
- compare rates from multiple suppliers
Streamline production processes
Analyse your production workflow to identify inefficiencies and reduce waste.
Automation can decrease labour costs and increase output consistency. Before investing, assess how changes will affect both your COGS and overall return on investment.
Optimise inventory levels
Use data analytics to forecast demand and maintain optimal inventory levels.
Review your product mix regularly. Consider discontinuing slow-moving items that tie up capital without generating returns.
Reduce freight costs
Explore alternative shipping methods that balance cost and delivery time.
Ways to reduce freight costs:
- consolidate shipments to access bulk rates
- negotiate volume discounts with carriers
- consider third-party logistics providers for better rates
Simplify COGS tracking with Xero
Managing COGS can be simple. Xero accounting software helps you track costs, manage inventory, and generate reports that show exactly where your money goes.
With Xero, you can:
- access real-time COGS reporting and analytics
- manage expenses and inventory in one place
- find COGS in your P&L and income statements automatically
Accurate COGS tracking helps you set better prices, boost profit margins, and make confident business decisions.
Ready to simplify your financial management? Get one month free and see how Xero can help your business grow.
FAQs on COGS
Common questions about calculating and managing cost of goods sold.
What is the difference between cost of goods sold and cost of sales?
These terms are often used interchangeably, but there’s a subtle difference.
COGS focuses on direct costs of creating or purchasing products. Cost of sales may include COGS plus additional revenue-related expenses like transaction fees, sales commissions, or customer acquisition costs.
Service and digital businesses are more likely to use “cost of sales” to capture these broader expenses.
How often should I calculate COGS?
Most businesses calculate COGS at the end of each accounting period: monthly, quarterly, or annually.
Calculate more frequently if you have high inventory turnover or need real-time profitability insights. Talk to your accountant for advice tailored to your business.
My business is service-based. Do I still have COGS?
Yes, service businesses have costs equivalent to COGS, often called “cost of services” or “cost of revenue.”
For service businesses, this typically includes:
- direct labour costs for delivering services
- software subscriptions used in service delivery
- materials or supplies consumed per project
How does COGS affect my gross profit margin?
COGS directly determines your gross profit margin. The formula is: (Revenue − COGS) ÷ Revenue = Gross profit margin.
Lower COGS means higher gross profit margin. For example, if you sell €100,000 worth of products with €60,000 in COGS, your gross profit margin is 40%. Reducing COGS to €50,000 increases your margin to 50%.
How do I calculate and record COGS in Xero for untracked (periodic) inventory?
Xero can’t calculate COGS automatically for untracked items, so count closing stock, apply the formula and post a manual journal to cost of sales. In that journal, adjust a current asset stock account, as Inventory-type accounts are reserved for tracked inventory and can’t be used on manual journals. Check these journals with your accountant.
What are common COGS calculation mistakes?
The most common COGS mistakes include:
- including indirect costs: adding rent, marketing, or administrative salaries that belong in operating expenses
- inconsistent inventory counts: using different methods to value beginning and ending inventory
- missing freight or storage costs: forgetting to include shipping and warehousing when they apply to your business
- mixing accounting methods: switching between FIFO, LIFO, or average cost mid-year, as accounting standards require the chosen formula to be consistently applied to all inventories of a similar nature
Consistent tracking and accounting software help prevent these errors.
Disclaimer
Xero does not provide accounting, tax, business or legal advice. This guide has been provided for information purposes only. You should consult your own professional advisors for advice directly relating to your business or before taking action in relation to any of the content provided.
Start using Xero for free
Access Xero features for 30 days, then decide which plan best suits your business.