Guide

Cost of goods sold (COGS): what it is and how to calculate it

Learn what COGS is, how to calculate it step by step, and how to record it with or without inventory tracking.

A person moving their orders to a van full of boxes

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

  • COGS is the direct cost of the goods you sell, worked out as beginning inventory plus purchases minus ending inventory
  • Revenue minus COGS gives you gross profit, so accurate figures help you set prices and protect your margins
  • You can record COGS without tracking units by using the periodic method and a stocktake at the end of each period
  • Malaysian businesses can value stock using FIFO or weighted average, while LIFO is disallowed under both MPERS and MFRS

What is COGS?

Cost of goods sold (COGS) is the direct cost of making or buying the products you sell during a period. It covers materials, production labour and other costs tied to those goods, while general running costs sit elsewhere.

The basic formula is beginning inventory + purchases − ending inventory = COGS. On your profit and loss statement, COGS sits directly below revenue, and revenue − COGS = gross profit. COGS is also called cost of sales.

Picture a phone accessories shop in Johor Bahru that sells a case for RM40 after buying it in for RM15. That RM15 is the cost of the goods sold, and the remaining RM25 is gross profit.

Accounting software that helps you manage your expenses and track stock levels keeps these figures up to date. That way, you always know what each sale really costs you.

What’s included in COGS

Cost of goods sold includes every cost directly tied to producing or buying the products you sell. The core costs usually include:

  • raw materials and components that become part of the finished product
  • wages for staff who physically make or assemble your products
  • manufacturing overheads, such as factory rent, equipment depreciation and production utilities

Some businesses also count costs that vary by industry. Depending on how you operate, these can include:

  • freight and shipping to bring in raw materials or deliver finished goods
  • warehousing costs for stock you hold
  • payment processing fees tied directly to sales
  • sales commissions paid on units sold

Here’s a simple test: if a cost would disappear when you stopped producing or selling a product, it likely belongs here.

What’s excluded from COGS

COGS leaves out indirect costs, which belong in your operating expenses instead. Common examples include:

  • rent for office space, since only factory or warehouse rent used for production qualifies
  • marketing and advertising, which promote products rather than make them
  • salaries for managers, accountants and office staff
  • general overheads, such as office supplies, software subscriptions and utilities for non-production spaces
  • research and development to design new products before production begins
  • delivery to customers, which some businesses treat as a selling cost (check with your accountant)

Getting this split right matters because misclassified expenses distort your gross profit. That affects your pricing, your tax calculations and how lenders read your accounts.

Why COGS is important for small businesses

COGS shows you the true cost of each sale, which helps you set prices and measure profitability. Tracking this figure closely lets you spot pressure on your margins early. It supports better decisions in six areas.

Pricing

Your cost per unit sets your pricing floor, because each sale needs to bring in more than it costs you. When material or labour costs rise, your cost records show whether to absorb the increase or adjust your prices.

Profitability

Lower direct costs mean higher gross profit. If you cut production costs while keeping prices steady, more of every sale stays in the business.

Gross profit is one layer of the picture. Your operating profit also subtracts wages, rent, depreciation and other running costs.

Inventory management

Tracking costs alongside sales shows which products earn their shelf space. You can spot slow sellers, adjust reorder points and free up cash tied to excess stock before it needs writing down.

Taxes

Cost of goods sold is generally deductible against your business income, which lowers the income you pay tax on. Accurate records help you claim what you’re entitled to and keep your books ready for review.

Rules on what qualifies can change, so check with the Inland Revenue Board of Malaysia (LHDN) or your accountant.

Understanding your financial health

This figure feeds directly into your gross profit margin, one of the first numbers lenders and partners check. It also shapes other profitability ratios that show how efficiently your business turns sales into profit.

Strategic decision-making

Cost data also informs bigger moves. When you know your true production costs, you can confidently weigh up new product lines, automation or changes to how you distribute goods.

COGS and different business models

Most businesses have COGS, but the costs you track depend on what you sell. Here’s how it typically works for each business type:

  • Manufacturers count raw materials, direct labour and production overheads such as material handling
  • Retailers use beginning inventory, purchases and ending inventory for the period
  • Service businesses count direct labour and any materials used to deliver the work

The next section shows the formulas retailers and manufacturers use.

How to calculate COGS

You calculate it by adding up the direct cost of the goods you sold in a period. Retailers track stock values at the start and end of the period, while manufacturers add up costs along the production process.

Retail COGS formula

Retailers typically use this formula: beginning inventory + purchases − ending inventory = COGS. It’s the foundation of inventory accounting for most shops.

Beginning inventory is the value of stock at the start of the period. Purchases are the cost of stock bought during it, and ending inventory is the value left at the end.

This formula tracks changes in stock value rather than individual sales. That means it automatically captures goods that were damaged, thrown away or stolen.

Cost of goods sold formula used by retailers for inventory accounting.

Manufacturing COGS formula

Manufacturers have longer supply chains, so they add up each cost on the product’s journey to the customer. The formula is raw materials + manufacturing costs + storage costs + freight = COGS.

Raw materials are the direct materials used in production. Manufacturing costs cover labour, equipment and facility costs, while storage and freight cover holding stock and moving materials or products.

Some manufacturers leave warehousing or freight out of COGS, so ask your accountant which approach fits your business. In accounting software like Xero, COGS appears in your profit and loss report.

How to calculate COGS step by step

This worked example applies the retail formula to one business: a batik shop in Penang. It covers the July–September quarter, and each step builds on the one before.

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.

1. Find your beginning inventory

Your beginning inventory is the value of stock on hand on the first day of the period. It should match the ending inventory on last period’s balance sheet. The batik shop starts 1 July with stock worth RM12,000.

2. Add purchases and direct costs

Next, total what you spent buying stock during the period, plus direct costs such as inbound freight. The shop buys RM30,000 of stock and pays RM1,500 to ship it in, so purchases come to RM31,500.

3. Count your ending inventory

At the end of the period, count what’s left and value it at cost, or at net realisable value if that’s lower. On 30 September, the shop’s stocktake values its remaining stock at RM9,500.

4. Apply the formula

Now put the three figures into the formula: RM12,000 + RM31,500 − RM9,500 = RM34,000. That’s the cost of everything the shop sold in the quarter, including any stock lost or damaged.

5. Check the result against revenue

Subtract this figure from revenue to get gross profit, then divide gross profit by revenue for your gross margin. The shop’s quarterly sales are RM68,000, so gross profit is RM34,000 and gross margin is 50%.

Compare this margin with previous quarters to see the trend. A steady gross margin supports a healthy overall profit margin, and if it slips, review supplier prices and discounting first.

How to record COGS without inventory tracking (periodic method)

If you buy stock straight into an expense or purchases account without tracking units, you can still work out COGS with the periodic method. You record purchases as they happen, then calculate the cost of goods sold once at the end of each period.

Here’s how the periodic method works:

  1. Record every stock purchase to a purchases or COGS account throughout the period.
  2. Run a stocktake on the last day of the period and value what’s left.
  3. Post an adjusting entry that moves the value of closing stock out of COGS and onto your balance sheet as inventory.
  4. Move last period’s closing stock back into COGS, since that stock was available for sale this period.

Together, these entries move the change in stock into your cost figure, giving the same result as the retail formula. Say a Melaka hardware shop books RM20,000 of purchases in March, and its stock rises from RM5,000 to RM6,000. The RM1,000 increase comes off purchases, leaving COGS of RM19,000.

The perpetual method takes a different approach: it updates inventory and COGS every time you buy or sell an item. You see margins in real time, and you need item-level records for every product.

The periodic method suits businesses with a small product range and simple stock. It’s worth moving to the perpetual method when:

  • your number of stock keeping units (SKUs) grows beyond what a quick stocktake can handle
  • you want margin figures by product or by week
  • stock losses become hard to trace between counts
  • you sell through several channels, such as a shop and an online store

An inventory management system connected to your accounts updates stock values and COGS as you trade. That gives you current margins without waiting for a stocktake.

Examples of COGS

These quick examples show the calculation for three types of business. Each one uses the formula that suits its business model.

Retail example

A clothing boutique starts the quarter with RM10,000 of stock and buys RM25,000 more. At the end of the quarter, RM8,000 of stock remains.

RM10,000 + RM25,000 − RM8,000 = RM27,000 COGS. The boutique spent RM27,000 on the stock it actually sold that quarter.

Manufacturing example

A furniture maker buys RM7,000 of timber and hardware. It spends RM3,000 on workshop labour and utilities, plus RM1,200 to ship finished pieces.

RM7,000 + RM3,000 + RM1,200 = RM11,200 COGS.

Service business example

A landscaping company pays RM2,000 in crew wages for a project, plus RM500 for plants and materials.

RM2,000 + RM500 = RM2,500 COGS. Labour is usually the main direct cost for service businesses like this one.

Tips for managing and reducing COGS

Cutting direct costs lifts the gross profit on every sale without raising your prices. These four areas are good places to start.

Negotiate with suppliers

Talk to your suppliers about pricing regularly. Long-term contracts or bulk orders can unlock volume discounts, and comparing quotes keeps your costs competitive.

Improve production processes

Review your production workflow to find waste and wasted time. Automation can lower labour costs and improve consistency, so weigh the upfront cost against the savings you expect.

Optimise inventory levels

Use sales data to forecast demand and avoid overstocking. Review your product mix often, and consider dropping slow sellers that tie up cash.

Reduce freight costs

Compare shipping options to find the right balance of cost and speed. Combining shipments can unlock bulk rates, and negotiating with carriers or using a third-party logistics provider can cut costs further.

COGS accounting methods

Your inventory valuation method decides which purchase costs you expense when prices change. When you sell stock, its cost moves from your balance sheet to your profit and loss statement as COGS.

Malaysian private entities report under either the Malaysian Private Entities Reporting Standard (MPERS) or Malaysian Financial Reporting Standards (MFRS). MPERS applies from 1 January 2016 and adopts the International Financial Reporting Standard for Small and Medium-sized Entities (IFRS for SMEs) almost word for word.

MFRS is identical to International Financial Reporting Standards (IFRS), and its MFRS 102 Inventories standard matches International Accounting Standard (IAS) 2 Inventories. Under both frameworks, you measure inventory at the lower of cost and net realisable value.

Here’s how the four main methods compare:

  • FIFO (first in, first out) assumes your oldest stock sells first, so rising prices mean lower COGS and higher profit. MPERS and MFRS permit it.
  • LIFO (last in, first out) assumes your newest stock sells first, so rising prices mean higher COGS and lower profit. MPERS and MFRS disallow it.
  • Weighted average cost divides total stock cost by units available, so rising prices lift costs gradually. MPERS and MFRS permit it.
  • Specific identification tracks each item’s exact cost, suiting unique, high-value goods such as vehicles or jewellery. Both frameworks apply it to non-interchangeable items.

The Malaysian Accounting Standards Board (MASB) comparison of Malaysian reporting frameworks confirms LIFO is disallowed under MPERS and MFRS. Ecovis’s guide to the MPERS transition also notes MPERS permits FIFO or weighted average.

Manage your COGS with Xero

Accurate cost figures help you price with confidence, protect your margins and keep your tax records in order. Xero accounting software helps you stay on top of them with:

  • real-time reports that show your costs and margins as they change
  • expense tracking that puts each cost in the right account from the start
  • inventory tracking that updates stock levels and values as you trade
  • financial insights that help you spot trends and plan ahead

Ready to take control of your costs? Try Xero and get one month free to see how easy managing your business finances can be.

Want help setting up your cost tracking? Find a bookkeeper or accountant through Xero Advisors.

FAQs on COGS

Here are answers to common questions small business owners ask about the cost of goods sold.

What’s the difference between COGS and operating expenses?

COGS reduces revenue to give you gross profit, while operating expenses such as rent and marketing come off gross profit to give you operating profit. Keeping them separate shows whether a margin problem comes from your products or your overheads.

What is the difference between cost of goods sold and cost of sales?

The terms are often used interchangeably, and cost of goods sold covers only the direct cost of producing or buying goods. Cost of sales can be broader, adding transaction fees, sales commissions or customer acquisition costs depending on your industry.

How often should I calculate COGS?

Most businesses calculate it at the end of each accounting period, whether that’s monthly, quarterly or yearly. If your stock turns over quickly, monthly or weekly checks give you a clearer view of your margins.

Can I estimate my COGS?

Yes, an estimate based on your usual markup works for early planning or interim reports. For your year-end accounts and tax return, you’ll need figures backed by a stocktake and purchase records.

My business is service-based. Do I still have COGS?

Yes, service businesses have direct costs too. They include wages for staff who deliver the work, plus materials and software used directly on client jobs.

Are salaries included in COGS?

Only wages for staff who directly make products or deliver services count. Salaries for managers, admin and office staff are operating expenses.

What is the difference between COGS and product cost?

Product cost is the total cost to make or buy an item, while COGS is the product cost of items you’ve actually sold. Unsold stock stays on your balance sheet as an asset until it sells.

What’s the difference between the periodic and perpetual inventory methods?

The periodic method works out your costs at the end of a period from a stocktake, while the perpetual method updates them with every sale. Perpetual records also reveal stock losses, because you can compare what you count with what your records expect.

Can I use LIFO in Malaysia?

LIFO is disallowed under both MPERS and MFRS, so use FIFO or weighted average instead. If you use costing software set up for another country, check its valuation setting matches.

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.