How to use the cost of goods sold formula

Two shop-owners walk alongside grocery shelves and take inventory of cheeses and other items using a tabletImage: Two shop-owners walk alongside grocery shelves and take inventory of cheeses and other items using a tablet

In a Nutshell

Cost of goods sold (COGS) is the cost of producing the goods sold by a company. The formula for determining cost of goods sold is beginning inventory plus purchases made during the period minus ending inventory.
Editorial Note: Intuit Credit Karma receives compensation from third-party advertisers, but that doesn’t affect our editors’ opinions. Our third-party advertisers don’t review, approve or endorse our editorial content. Information about financial products not offered on Credit Karma is collected independently. Our content is accurate to the best of our knowledge when posted.

As a company selling products, you need to know the costs of creating those products. That’s where the cost of goods sold formula comes in. Beyond calculating the costs to produce a good, the COGS formula can also reveal profits for an accounting period, if price changes are necessary or whether you need to trim production costs.

Understanding how to calculate the cost of goods sold can help you feel more informed about the products you’re purchasing — or producing.

As the name suggests, cost of goods sold is the cost of producing the goods sold by a company. It includes the cost of materials and labor directly related to that good. However, it excludes indirect expenses such as distribution costs.

We’ll review the cost of goods sold formula, the factors that go into the formula and what else you need to consider when calculating cost of goods sold.



What is the cost of goods sold formula?

When selling a product, you need to understand the production costs associated with it in a given period, ​​which could be a month, quarter or year. You can do that by using the cost of goods sold formula. It’s a straightforward calculation that accounts for the beginning inventory, ending inventory and purchases during the accounting period. Here is a simple breakdown of the cost of goods sold formula.

cost-of-goods-formulaImage: cost-of-goods-formula

How do you calculate cost of goods sold?

To calculate cost of goods sold, you have to determine your beginning inventory — meaning your merchandise, including raw materials and supplies — at the beginning of your accounting period. Then add in the new inventory purchased during that period and subtract the ending inventory — meaning the inventory that is remaining at the end of your accounting period. The extended COGS formula also accounts for returns, allowances, discounts and freight charges, but we’re sticking to the basics in this explanation.

Taking it one step at a time can help you understand the COGS formula and find the true cost behind the goods you sell. Here’s how you do it.

Step 1: Identify direct and indirect costs

Whether you manufacture or resell products, the COGS formula allows you to deduct all of the costs associated with them. The first step is to differentiate the direct costs, which are included in the COGS calculation, from indirect costs, which are not.

Direct costs

Direct costs are the costs tied to the production or purchase of a product. These costs can fluctuate depending on the production level. Here are some direct costs examples.

  • Direct labor
  • Direct materials
  • Manufacturing supplies
  • Fuel consumption
  • Power consumption

Indirect costs

Indirect costs go beyond costs tied to the production of a product. They include the costs involved in maintaining your business plan and running the company. Indirect costs are not included in the COGS calculation. Here are some examples.

  • Rent
  • Interest
  • Taxes
  • Storage
  • Repackaging
  • Handling
  • Administrative costs

Step 2: Determine beginning inventory

Now it’s time to determine your beginning inventory. The beginning inventory will be the amount of inventory leftover from the previous time period, which could be a month, quarter or year. Beginning inventory is your merchandise, including raw materials, supplies and finished and unfinished products that were not sold in the previous period.

Keep in mind that your beginning inventory cost for that time period should be exactly the same as the ending inventory from the previous period.

Step 3: Tally up items added to your inventory

After determining your beginning inventory, you also have to account for any inventory purchases throughout the period. It’s important to keep track of the cost of shipment and manufacturing for each product, which adds to the inventory costs during the period.

Step 4: Determine ending inventory

 The ending inventory is the value of merchandise remaining after the period is over. It can be determined by taking a physical inventory of products or estimating that amount. The ending inventory costs can also be reduced if any inventory is damaged, obsolete or worthless.

Step 5: Plug it into the cost of goods sold equation

Now that you have all the information to calculate cost of goods sold, all there’s left to do is plug it into the COGS formula. The example below shows the COGS formula in action:

Let’s say you want to calculate the cost of goods sold in a monthly period. After accounting for the direct costs, you find out that you have a beginning inventory amounting to $30,000. Throughout the month, you purchase an additional $5,000 worth of inventory. Finally, after taking inventory of the products you have at the end of the month, you find that there’s $2,000 worth of ending inventory.

Using the cost of goods sold equation, you can plug those numbers in as such and discover your cost of goods sold is $33,000:

COGS = beginning inventory + purchases during the period – ending inventory

COGS = $30,000 + $5,000 – $2,000

COGS = $33,000

Accounting for cost of goods sold

Having a sound and consistent strategy for determining COGS is important for staying on top of expenses.

There are different accounting methods used to record the level of inventory during an accounting period. The accounting method you choose can influence the value of the cost of goods sold. The four main methods of accounting for the cost of goods sold are first in, first out; last in, first out; weighted average cost; and specific identification.

FIFO-vs-LIFOImage: FIFO-vs-LIFO

FIFO: First in, first out

The first-in, first-out method, also known as FIFO, is when the earliest goods that were purchased are sold first. Since merchandise prices have a tendency of going up, by using the FIFO method, the company would be selling the least expensive item first. This translates into a lower COGS compared to the LIFO method. In this case, the net income tends to increase over time.

LIFO: Last in, first out

The last-in, first-out method, also known as LIFO, is when the most recent goods added to the inventory are sold first. If there’s a rise in prices, like during periods of inflation, a company using the LIFO method would be essentially selling the goods with the highest cost first. This leads to a higher COGS compared to the FIFO method. By using this method, the net income tends to decrease over time.

Average cost method

The average cost method is when a company uses the average price of all goods in stock to calculate the beginning and ending inventory costs. This means that there will be less of an impact on the COGS by higher costs when purchasing inventory.

Special identification method

The special identification method accounts for items individually rather than in a group. This requires marking and tracking each individual item in the group, and is generally used for high-value items like cars or expensive jewelry.

COGS vs. operating expenses

Business owners are likely familiar with the term “operating expenses.” However, this shouldn’t be confused with the cost of goods sold. Although they are both company expenditures, operating expenses are not directly tied to the production of goods.

Operating costs are expenses that keep a company up and running, including rent, equipment, insurance, salaries, marketing and office supplies. Sales tax, for instance, could be viewed as an operating expense or COGS. If you sell a product with sales tax included in the price, you would classify it as COGS.

COGS vs. cost of revenue

Another thing to consider when calculating COGS is that it’s not the same as the cost of revenue. Cost of revenue takes into consideration some of the indirect costs associated with sales, such as marketing and distribution, while COGS does not take any indirect costs into consideration.

By subtracting COGS from the cost of revenue, you can determine a company’s gross income, which refers to what a company has left after selling its products and taking into account COGS.

Exclusions from COGS

Since service companies do not have an inventory to sell and COGS accounts for the cost of inventory, they can’t use COGS because they don’t sell a product — they would instead calculate the cost of services. Examples of service companies are accounting firms, law offices, consultants and real estate appraisers.


What’s next?

Running a business requires tactical planning and balancing many moving parts. To ensure a company is making a profit and paying fair salaries, business owners should have a well-rounded view of the costs associated with their goods sold.

Following this step-by-step guide to learn how to use the cost of goods sold formula is a good starting point. You may want to consider consulting an expert, such as an accountant or financial adviser, when calculating the cost of goods sold as part of your business.

Sourcing