Simple formula
(Revenue - Cost of Goods Sold) / RevenueThe formula uses these inputs:
- Revenue: enter your value in the calculator or spreadsheet.
- Cost of Goods Sold: enter your value in the calculator or spreadsheet.
Excel formula
Use this Excel formula as a starting point. Replace the sample cell references with the cells in your worksheet.
=IFERROR((B2-C2)/B2,0)
Google Sheets formula
In most cases, the Google Sheets version uses the same structure as Excel.
=IFERROR((B2-C2)/B2,0)
Power BI DAX measure
Use this DAX pattern as a starting point and rename measures or columns to match your Power BI model.
Gross Margin =
DIVIDE(
[Revenue] - [Cost of Goods Sold],
[Revenue]
)
SQL example
This generic SQL pattern can be adapted to your warehouse table names and column names.
SELECT
(revenue - cost_of_goods_sold) / NULLIF(revenue, 0) AS gross_margin
FROM kpi_data;
Gross Margin calculator
How to interpret Gross Margin
Use this KPI with trend data, targets, and related metrics. A single value is less useful than a consistent definition tracked over time.
Common mistakes
- Mixing different time periods in the numerator and denominator.
- Using totals that do not match the KPI definition used by your company.
- Comparing results across teams or industries without context.
Related KPI formulas
Frequently asked questions
What is the Gross Margin formula?
The common Gross Margin formula is: (Revenue - Cost of Goods Sold) / Revenue.
How do you calculate Gross Margin in Excel?
Use this Excel formula pattern: =IFERROR((B2-C2)/B2,0). Replace the cell references with your own data.
Can this KPI be calculated in Power BI?
Yes. Use the DAX measure on this page as a starting point and adjust table and column names to match your model.