To calculate cost of goods sold from a trial balance, take the opening inventory balance, add the purchases and freight-in accounts, subtract purchase returns and discounts, and then subtract closing inventory from your stock count. For example, $18,000 opening inventory plus $46,000 net cost of purchases less $21,000 closing inventory equals $43,000. In a perpetual system, COGS is already a ledger balance.
Key takeaways
- Which formula you use depends on your inventory system. In a periodic system, the trial balance holds opening inventory plus separate purchase accounts, and you calculate COGS. In a perpetual system, the trial balance already shows a COGS balance.
- On an unadjusted periodic trial balance, the Inventory account still shows the opening balance, not the closing one. Take closing inventory from your count.
- Pick up every cost account: purchases, freight-in, purchase returns and purchase discounts. Missing one changes COGS by exactly its amount.
- A balanced trial balance only proves debits equal credits. It does not prove closing inventory or COGS is right.
- After you calculate COGS, post an adjusting entry so the ledger shows the new inventory balance and a single COGS balance.
What does a trial balance show, and why does COGS take extra work?
A trial balance is a list of every ledger account with its debit or credit balance at a date. Total debits must equal total credits, which is the first check that the books are internally consistent. If you need a refresher on how the debit and credit rules produce those balances, see the debit and credit rules.
COGS needs extra work because, in a periodic inventory system, no one posts a cost entry when you make a sale. During the month you debit Purchases when you buy and credit Sales when you sell. You only find out what the sales cost at the end, when you count the stock. So the trial balance taken before that step contains the ingredients of COGS but no COGS figure. In a perpetual system, every sale posts its cost at the time, so the trial balance already contains a COGS account. Our companion lesson on inventory accounting journal entries shows the difference entry by entry.
Step 1: Decide whether the books are periodic or perpetual
Look at the trial balance. These signs tell you which system you have:
| What you see | What it means |
|---|---|
| Accounts called Purchases, Purchase returns, Purchase discounts, Freight-in; no COGS account; Inventory equals last month's closing figure | Periodic. You calculate COGS. |
| An account called Cost of goods sold with a balance; no Purchases account; Inventory moves during the month | Perpetual. Read COGS from the account, then check it. |
| Both Purchases and COGS accounts with balances | Mixed or partly adjusted. Find out what was posted before you calculate. |
The rest of this lesson works through the periodic case, because that is where you have to calculate. The perpetual case is covered near the end.
Step 2: Read the unadjusted trial balance
Here is the unadjusted trial balance of the fictional shop Lakeside Home Goods at 31 March, prepared under a periodic system. The figures in this example are fictional.
| Account | Debit ($) | Credit ($) |
|---|---|---|
| Cash | 12,000 | |
| Accounts receivable | 9,500 | |
| Inventory (opening balance) | 18,000 | |
| Equipment | 20,000 | |
| Accounts payable | 14,000 | |
| Owner's capital | 39,000 | |
| Sales | 72,000 | |
| Sales returns | 2,000 | |
| Purchases | 46,000 | |
| Purchase returns | 1,500 | |
| Purchase discounts | 500 | |
| Freight-in | 2,000 | |
| Rent | 5,000 | |
| Wages | 9,000 | |
| Utilities | 1,200 | |
| Other operating expenses | 2,300 | |
| Total | 127,000 | 127,000 |
Debits and credits both total $127,000, so the trial balance balances. Note what is still missing: no one has recorded the closing stock yet, and the Inventory balance of $18,000 is the stock Lakeside had on 1 March.
In a periodic system the Inventory account is not touched during the month. The balance on an unadjusted trial balance is the opening figure. If you read $18,000 as the closing balance and use it in the formula, you are saying nothing changed all month, and COGS will be wrong by the full change in stock.
Step 3: Pick the right accounts for the COGS calculation
Go down the list and pull out only the accounts that belong in the cost of goods sold section. Everything else stays where it is.
| Account on the trial balance | Used in COGS? | Effect |
|---|---|---|
| Inventory (opening) 18,000 Dr | Yes | Add |
| Purchases 46,000 Dr | Yes | Add |
| Freight-in 2,000 Dr | Yes | Add |
| Purchase returns 1,500 Cr | Yes | Subtract |
| Purchase discounts 500 Cr | Yes | Subtract |
| Sales 72,000 Cr and Sales returns 2,000 Dr | No (revenue side) | Used later for gross profit |
| Rent, wages, utilities, other 17,500 Dr | No (operating expenses) | Below gross profit |
| Cash, receivables, equipment, payables, capital | No (balance sheet) | Not part of profit |
If your trial balance uses different names, such as "Carriage inwards" or "Inward freight", map them to the same role. A debit-balance account that adds to the cost of getting stock into the shop belongs with purchases. A credit-balance account that reduces what you paid for stock belongs with returns and discounts. Items that you pay to deliver goods to customers (freight-out) normally stay in operating expenses.
Step 4: Get closing inventory from a count, not from the ledger
Closing inventory is the one number that is not on the unadjusted trial balance. Take it from the stock count at month-end, valued at cost (or at net realisable value if that is lower). For Lakeside, the count and valuation come to $21,000. If you need a method for the count, follow the step-by-step stock opname, and for the concept see what is stock opname.
The valuation method matters here. If you use FIFO or average cost, the closing figure is the unit cost times quantity under that method. The lesson on FIFO vs average costing shows how they differ.
Step 5: Calculate COGS
COGS = Opening inventory + Purchases + Freight-in − Purchase returns − Purchase discounts − Closing inventory
Opening inventory is the unadjusted trial-balance figure; closing inventory comes from the count.
| Step | Calculation | Result ($) |
|---|---|---|
| Opening inventory | From trial balance | 18,000 |
| Add: Purchases | From trial balance | 46,000 |
| Less: Purchase returns | From trial balance | 1,500 |
| Less: Purchase discounts | From trial balance | 500 |
| Net purchases | 46,000 − 1,500 − 500 | 44,000 |
| Add: Freight-in | From trial balance | 2,000 |
| Net cost of purchases | 44,000 + 2,000 | 46,000 |
| Cost of goods available for sale | 18,000 + 46,000 | 64,000 |
| Less: Closing inventory | From stock count | 21,000 |
| Cost of goods sold | 64,000 − 21,000 | 43,000 |
To confirm, net sales are $72,000 − $2,000 = $70,000, and gross profit is $70,000 − $43,000 = $27,000, a gross margin of 38.6%. That agrees with the income statement figure in the lesson on calculating COGS from an income statement.
Step 6: Post the adjusting entries so the ledger agrees
Calculating COGS on paper is not enough. The ledger still shows Inventory at $18,000 and has no COGS balance. Post two entries at month-end. The first moves opening inventory and all purchase-related accounts into COGS:
| Account | Debit ($) | Credit ($) |
|---|---|---|
| Cost of goods sold | 64,000 | |
| Purchase returns | 1,500 | |
| Purchase discounts | 500 | |
| Inventory (opening) | 18,000 | |
| Purchases | 46,000 | |
| Freight-in | 2,000 | |
| Total | 66,000 | 66,000 |
The second records the stock still on hand:
| Account | Debit ($) | Credit ($) |
|---|---|---|
| Inventory (closing) | 21,000 | |
| Cost of goods sold | 21,000 | |
| Total | 21,000 | 21,000 |
After both, COGS has a debit balance of $64,000 − $21,000 = $43,000, Inventory shows $21,000, and Purchases, Purchase returns, Purchase discounts and Freight-in are all zero. Many teams record this as one combined entry, or as part of closing entries; the end result is identical. The general idea of month-end adjustments is covered in adjusting journal entries, and the mechanics of writing entries by hand are in the general journal lesson.
Step 7: Check the adjusted trial balance
Prepare the adjusted trial balance and confirm it still balances. Only the inventory-related lines changed:
| Account | Debit ($) | Credit ($) |
|---|---|---|
| Cash | 12,000 | |
| Accounts receivable | 9,500 | |
| Inventory | 21,000 | |
| Equipment | 20,000 | |
| Accounts payable | 14,000 | |
| Owner's capital | 39,000 | |
| Sales | 72,000 | |
| Sales returns | 2,000 | |
| Cost of goods sold | 43,000 | |
| Rent | 5,000 | |
| Wages | 9,000 | |
| Utilities | 1,200 | |
| Other operating expenses | 2,300 | |
| Total | 125,000 | 125,000 |
The totals are lower than before ($125,000 against $127,000) because four accounts that carried the cost of buying stock have been folded into COGS. The balance sheet now shows Inventory of $21,000, which matches the count. For a longer example of preparing and using a trial balance, see the trial balance worked example.
What if your books are perpetual?
If the system posts cost at each sale, the trial balance for the same month already contains the answer. The Purchases and related accounts do not exist because purchases were debited to Inventory when they happened, and the cost of each sale was moved out of Inventory into COGS. Lakeside's perpetual trial balance would look like the adjusted one above: Inventory $21,000 and COGS $43,000.
In that case you do not calculate COGS; you test it. Use the roll-forward:
| Check | Calculation | Result ($) |
|---|---|---|
| Opening inventory | Last month's ledger close | 18,000 |
| Add: net cost of purchases posted to Inventory | 46,000 − 1,500 − 500 + 2,000 | 46,000 |
| Less: COGS balance on the trial balance | 43,000 | |
| Expected closing inventory | 18,000 + 46,000 − 43,000 | 21,000 |
| Counted inventory | Stock count | 21,000 |
| Difference | Counted − expected | 0 |
A difference is not a COGS error to be hidden. In a perpetual system, a shortage is usually recorded as a separate adjustment (for example, to a shrinkage expense) once you find it, so you can see it. Under a periodic system the same shortage would have been absorbed into COGS without being visible. That visibility is a practical reason to prefer perpetual records. The retail lesson on calculating retail COGS goes deeper on that point.
Common mistakes when calculating COGS from a trial balance
- Using the trial balance Inventory as closing stock. Covered above. It is the opening figure in a periodic system.
- Leaving out freight-in. It is easy to miss because it often has a name like "carriage" or "delivery in".
- Adding returns and discounts instead of subtracting them. They have credit balances, so they reduce cost.
- Including freight-out or rent. These are operating expenses, not COGS.
- Counting closing stock at selling price. Inventory belongs on the books at cost (or lower net realisable value).
- Cut-off errors. Goods received before month-end but not yet entered, or invoiced but not yet received, shift COGS. Check the last few receipts and shipments around the count date.
More on typical errors appears in common mistakes in inventory and costing.
How inventory is valued and presented, and whether a periodic method is acceptable for tax or statutory accounts, varies by country. Treat this lesson as general education and check your local rules or a qualified adviser.
Reyuko uses a perpetual system, so its trial balance already carries Inventory and COGS accounts and you do not assemble COGS from purchase accounts. A goods receipt debits Inventory and credits GRNI until the purchase bill arrives (the bill then clears GRNI), and each sales invoice posts Dr COGS / Cr Inventory at the cost set for the product: Average, FIFO, LIFO or FEFO. Because every entry balances, total debits equal total credits on the trial balance, and the stock count then checks Inventory against what is physically on hand.
Reyuko