Gross margin is the percentage of revenue left after paying for the goods you sold: revenue minus cost of goods sold (COGS), divided by revenue, times 100.
Gross margin = (Revenue − Cost of goods sold) ÷ Revenue × 100
On the sample data below, six months come to 45.56%.
Why it matters
Gross margin sets the ceiling on everything else. Marketing, salaries and rent all come out of it, so a brand with thin gross margin has little room to spend on growth.
Worked example
The table shows the columns this metric needs from six months of a made-up subscription brand. Add each column up over the six months, then put the totals into the formula:
| Month | Revenue (net of discounts) | Cost of goods sold |
|---|---|---|
| 2026-01 | ₹4,12,000 | ₹2,26,600 |
| 2026-02 | ₹4,38,500 | ₹2,36,800 |
| 2026-03 | ₹4,71,200 | ₹2,59,200 |
| 2026-04 | ₹4,55,800 | ₹2,55,200 |
| 2026-05 | ₹5,02,300 | ₹2,71,200 |
| 2026-06 | ₹5,48,900 | ₹2,90,900 |
| Total | ₹28,28,700 | ₹15,39,900 |
(₹28,28,700 − ₹15,39,900) ÷ ₹28,28,700 × 100 = 45.56%
Add up first, then divide. Averaging the six monthly figures gives a slightly different answer, because it counts a small month the same as a large one.
Month by month
| Month | Gross margin |
|---|---|
| 2026-01 | 45.00% |
| 2026-02 | 46.00% |
| 2026-03 | 44.99% |
| 2026-04 | 44.01% |
| 2026-05 | 46.01% |
| 2026-06 | 47.00% |
Gross margin calculator
How to read it
A falling gross margin usually means deeper discounts, a shift to cheaper products, or rising supplier costs. Split it by product to find which.
Common mistakes
- Be consistent about what goes into COGS. Some brands include inbound freight and packaging, others put them in operating costs; either works if it never changes.
- Gross margin is a percentage; gross profit is the rupee amount. They can move in opposite directions.
- Margin and markup are different. A 50% markup on cost is a 33% margin on price.
Calculate gross margin in Excel, SQL or Python
The quickest version, for the sample sheet laid out as in the CSV (headers in row 1, months in rows 2 to 7):
=(SUM(B2:B7) - SUM(C2:C7)) / SUM(B2:B7)- Gross margin in Excel and Google Sheets — per-month formula and zero-safe version
- Gross margin in SQL — query by month and for the period
- Gross margin in Python (pandas) — pandas script with expected output
Related metrics
See all business metrics, or the statistics methods that sit behind them.
Questions people ask
- What is gross margin?
- Gross margin is the percentage of revenue left after paying for the goods you sold: revenue minus cost of goods sold (COGS), divided by revenue, times 100.
- How do you calculate gross margin?
- Gross margin = (Revenue − Cost of goods sold) ÷ Revenue × 100. For example, with six months of sample data: (₹28,28,700 − ₹15,39,900) ÷ ₹28,28,700 × 100 = 45.56%.
- What is the gross margin formula in Excel?
- With the sample data laid out as in the downloadable CSV, =(SUM(B2:B7) - SUM(C2:C7)) / SUM(B2:B7) gives the figure for the whole period (format the cell as a percentage). For one month, use =(B2 - C2) / B2 and fill it down.
- What is a good gross margin?
- There is no figure that is right for every business: it depends on your products, prices and channels. A falling gross margin usually means deeper discounts, a shift to cheaper products, or rising supplier costs. Split it by product to find which.
Check how stable it is
A metric moves for ordinary reasons as well as real ones. These methods separate the two: the spread shows what a normal month looks like, the moving average smooths it, the z-score flags a month that is out of line and the trend line shows the direction.
Guides
About the data on this page
The figures come from a small made-up dataset, printed above in full so you can check every number by hand. Download it as monthly.csv. The results are computed from those rows when the page is built, and the Excel formulas, SQL and Python on these pages are run against the same rows before publishing, so the code and the answers agree.
To get these numbers from your own data without writing formulas, try AnalyzeIt: ask in plain words and it shows the working behind every figure.
Legal entity
Devansh Yadav
Moradabad, Uttar Pradesh
Governing law: Courts at Moradabad, Uttar Pradesh
Phone: +91 8433475698
Legal: legal@analyzeit.in