Cost of goods sold for online shops: average, FIFO, date
How to calculate cost of goods sold for an online shop: weighted average, FIFO, by batch and by effective date, with a worked example and a cost table in Excel.
By The DataxLand team· · 7 min read
Cost of goods is usually the biggest expense for a shop selling physical products: in DataxLand sample data, cost of goods is about 52% of net revenue, more than marketplace fees and advertising combined. Yet in many profit and loss spreadsheets, cost of goods is a "purchase price" column typed in once and never changed, even though every batch arrives at a different price.
This post compares four ways online shops calculate cost of goods sold, shows how each one changes a month's profit on the same example, and explains how to keep a cost table with effective dates so SKU profit is not skewed every time purchase prices rise.
The numbers use DataxLand sample data (a simulated scented-candle and essential-oil shop, 1 Aug – 29 Oct 2026) and clearly stated illustrative assumptions alongside. They are not a real customer's numbers.
Cost of goods for the books vs for decisions
There are two different questions that are easy to mix up:
- Cost of goods in the accounting books: used for financial statements and tax filings. The inventory costing method is set by the applicable accounting regime; a business picks one method and applies it consistently. For businesses operating in Vietnam, for example, Circular 99/2025/TT-BTC sets out the corporate accounting regime; it was issued on 27 Oct 2025 and takes effect from 1 Jan 2026, applying to financial years starting on or after that date (according to the Ministry of Finance policy Q&A, read on 16 Nov 2026); small and medium-sized businesses may follow a separate regime. This part is your accountant's job; ask them which regime and method you use.
- Cost of goods for management: used to answer "is this SKU still profitable", "what price should we set", "which channel loses money". What matters here is that the cost is tied to the time of sale and available for every SKU, rather than matching the books to the last unit.
This post is about the second kind. When the two numbers differ, know why they differ instead of forcing them to be equal. This is not accounting or tax advice.
Four methods on the same example
Illustrative assumptions, with purchase prices taken from the sample data: product MH-KT-01 has a cost of 260,000 ₫ up to
30 Sep 2026 and 285,000 ₫ from 1 Oct 2026. Further assumed quantities: batch 1 of 100 units at 260,000 ₫ received in September,
batch 2 of 100 units at 285,000 ₫ received on 1 Oct; 80 units sold in September, 90 in October, at a selling price after discounts
of 450,000 ₫ per unit.
| Method | September COGS | October COGS | October gross profit (revenue 40,500,000 ₫) |
|---|---|---|---|
| First in, first out (FIFO) | 20,800,000 ₫ | 25,150,000 ₫ | 15,350,000 ₫ |
| Moving average (recalculated after each receipt) | 20,800,000 ₫ | 25,275,000 ₫ | 15,225,000 ₫ |
| Periodic average (whole quarter) | 21,800,000 ₫ | 24,525,000 ₫ | 15,975,000 ₫ |
| By effective date (price of the sale period) | 20,800,000 ₫ | 25,650,000 ₫ | 14,850,000 ₫ |
How each row is calculated:
- FIFO: October issues the remaining 20 units of batch 1 (5,200,000 ₫) and 70 units of batch 2 (19,950,000 ₫).
- Moving average: after batch 2 arrives, stock is 20 units at 260,000 ₫ and 100 units at 285,000 ₫, an average of 33,700,000 ÷ 120 = 280,833 ₫ per unit; 90 units come to 25,275,000 ₫.
- Periodic average: 200 units, 54,500,000 ₫ in total, an average of 272,500 ₫ per unit for every sale in the quarter.
- By effective date: each order uses the cost in effect on its date; October is 285,000 ₫ per unit.
October gross profit differs by up to 1,125,000 ₫ (about 2.8 percentage points of margin) purely because of the method. None of them is "wrong"; each answers a slightly different question.
Which method for management reports
| The question you need to answer | Suitable method | Why |
|---|---|---|
| Does September's profit change when October's stock arrives at a higher price? | FIFO, moving average, effective date | Past-period profit stays fixed |
| Setting the selling price for next week | Effective date | Reflects the current purchase price, not made cheaper by old batches |
| Matching the accounting books as closely as possible | The accounting method in use | Same rules |
| High-value goods tracked by batch (serial-numbered electronics) | Specific identification by batch | You know exactly which batch was sold |
What to avoid is a periodic average for weekly reports: the cost for the first weeks of the quarter is only known when the quarter ends, so September's profit in the example changes from 15,200,000 ₫ to 14,200,000 ₫ once the October batch arrives. On the dashboard, past profit simply "drops" without any order changing.
For most online shops, the most practical approach is cost of goods by effective date: each SKU has a cost table, and each row has a start date. When the purchase price changes, you add a new row instead of editing the old one.
Three cost mistakes that make profit look better than it is
- SKUs without a cost are treated as zero cost. Add a new product and forget its cost, and every order of that product looks almost 100% profitable. In the sample data, only 92.35% of revenue has a cost of goods; the remaining 7.65% is being counted at 0 ₫ cost. Always track this ratio next to the profit figure.
- Overwriting the old cost. Typing the new 285,000 ₫ into the cost cell for
MH-KT-01recalculates profit for every August and September order at the new price. Keep the history; do not overwrite. - Forgetting the cost of getting goods into the warehouse. Inbound freight, import duties and per-product packaging are part of the cost of goods sold. Delivery to the buyer is not; it belongs under shipping costs.
Build a cost table with effective dates in Excel
-
Create a sheet
cogswith four columns: Asku, Bunit_cost, Cvalid_from, Dvalid_to(leave blank if currently in effect).sku unit_cost valid_from valid_to MH-KT-01 260000 2026-08-01 2026-09-30 MH-KT-01 285000 2026-10-01 MH-NEN-03 95000 2026-08-01 -
Each time the purchase price changes: fill in
valid_tofor the old row and add a new row. Never delete a row. -
On the order-lines sheet (B is
sku, D isorder_date), look up the cost on the sale date (Excel 365):=XLOOKUP(1,(cogs!$A$2:$A$500=B2)*(cogs!$C$2:$C$500<=D2)*((cogs!$D$2:$D$500>=D2)+(cogs!$D$2:$D$500="")),cogs!$B$2:$B$500,"MISSING") -
Count the rows that return
MISSINGand calculate their share of revenue. That is the share of revenue without a cost of goods; put it at the top of the report. -
Check for duplicates: a SKU must not have two rows with overlapping dates. Use
COUNTIFSby SKU and date range to catch them.
(The cost of MH-NEN-03 in the table is an illustrative assumption.)
How DataxLand does this
DataxLand keeps cost of goods as a table with effective dates: each SKU can have several cost levels, each applying to a date range,
and the cost of each order line is taken from the order date. In the sample data, MH-KT-01 has a cost of 260,000 ₫ for an
order on 30 Sep and 285,000 ₫ for an order on 1 Oct, exactly as in the table above. A data check blocks the build when the cost table
has duplicate keys (for example the same SKU with the same start date), so no profit figure rests on an ambiguous cost.
You bring in cost of goods as a sheet in an Excel file (see the Excel connector) or from your inventory software through a connection. A cost coverage metric (the share of revenue with a cost of goods) sits next to profit after fees on the dashboard; the profit tile is labelled Incomplete when this share is below 100%. The definitions of cost of goods sold and contribution margin are in the metric handbook. When reading your data, Si proposes which column is the cost and which is the effective date; you approve before anything is built. Afterwards you can ask Si "which SKUs have no cost of goods" or "cost of goods in October vs September by product".
Frequently asked questions
Does a small shop need FIFO?
For management reports, usually not. Cost by effective date is simpler and good enough for decisions. For the books, follow your accounting regime and your accountant.
Should cost of goods include inbound shipping?
Yes. The cost of getting goods to your warehouse (inbound freight, import duties, per-product packaging) is part of the cost of goods. Delivery to the buyer goes under shipping costs.
How is the cost of free promotional gifts handled?
A gift still has a cost, even though its price is zero. Record it as a 0 ₫ order line with a cost of goods, so the order's profit reflects the true cost of the gift.
Is it a problem if profit on the dashboard differs from the accountant's report?
Differences from a different costing method or different recognition timing are normal. List the sources of difference (costing method, provisional fees, unallocated costs) so both sides are telling the same story.
Read next: How to calculate true profit on Shopee, TikTok Shop and Lazada · When Excel is not enough: when you need a data warehouse