A contribution margin calculator you can rebuild in a spreadsheet
A contribution margin calculator needs seven inputs, which are net revenue, orders, product cost, shipping per order, the payment fee rate, the fixed fee per order and ad spend. Twelve short formulas turn them into gross margin, contribution margin before and after ads, both ratios, the per order figure and the break-even return on ads.
What does a contribution margin calculator need?
A contribution margin calculator is a short list of inputs and a subtraction. For a store, seven inputs are enough. There is no widget on this page. You build the calculator in your own sheet, and then you own it.
Put labels in column A and values in column B.
| Cell | Input | Where to get it |
|---|---|---|
| B2 | Net revenue for the period | Your store's sales report: sales after discounts and refunds, before tax and shipping charged |
| B3 | Orders in the same period | The same report |
| B4 | Product cost as a share of net revenue | Cost of goods for the period divided by net revenue. Shopify holds it as cost per item on each product |
| B5 | Shipping cost per order | Carrier and warehouse invoices, less shipping charged to customers, divided by orders |
| B6 | Payment fee rate | Your processor's rate. Stripe and Shopify both list 2.9% as a standard online card rate |
| B7 | Fixed payment fee per order | The same pages list 30 cents |
| B8 | Ad spend for the period | The spend report in each ad platform, added together |
Keep the period the same for every row. Revenue for a month set against ad spend for a quarter is an easy way for this sheet to go wrong.
What are the cell formulas?
Twelve formulas, each one line. They work unchanged in Google Sheets and Excel.
| Cell | Result | Formula |
|---|---|---|
| B10 | Product cost | =B2*B4 |
| B11 | Gross margin | =B2-B10 |
| B12 | Shipping | =B3*B5 |
| B13 | Payment fees | =B2*B6+B3*B7 |
| B14 | Contribution margin before ads | =B11-B12-B13 |
| B15 | Contribution margin after ads | =B14-B8 |
| B16 | Ratio before ads | =IFERROR(B14/B2,"not enough data") |
| B17 | Ratio after ads | =IFERROR(B15/B2,"not enough data") |
| B18 | Average order value | =IFERROR(B2/B3,"not enough data") |
| B19 | Margin after ads per order | =IFERROR(B15/B3,"not enough data") |
| B20 | Break-even revenue per ad dollar | =IFERROR(B2/B14,"not enough data") |
| B21 | Actual revenue per ad dollar | =IFERROR(B2/B8,"not enough data") |
Format B4, B6, B16 and B17 as percentages. IFERROR returns its second argument when the first one fails, so an empty revenue or order cell shows "not enough data" where a spreadsheet would otherwise print a division error. A blank that says so is better than a zero that looks like a result.
The formulas follow the textbook definition. OpenStax's managerial accounting text defines contribution margin as sales less variable costs, and the ratio as that margin over sales. The contribution margin formula guide explains each cost line. This page only builds the sheet.
What should the sheet return on a filled example?
Type these inputs in and compare. They are 90 days of an example store. These are example figures, not customer results. The example store is far larger than most, so read the shares and ratios, not the totals.
| Cell | Input | Example value |
|---|---|---|
| B2 | Net revenue | $37,285,338.38 |
| B3 | Orders | 500,987 |
| B4 | Product cost share | 42% |
| B5 | Shipping per order | $7.50 |
| B6 | Payment fee rate | 2.9% |
| B7 | Fixed fee per order | $0.30 |
| B8 | Ad spend | $8,986,606.16 |
A correct sheet returns the following, by my arithmetic on that example data.
| Cell | Result | Expected value |
|---|---|---|
| B10 | Product cost | $15,659,842.12 |
| B11 | Gross margin | $21,625,496.26 |
| B12 | Shipping | $3,757,402.50 |
| B13 | Payment fees | $1,231,570.91 |
| B14 | Contribution margin before ads | $16,636,522.85 |
| B15 | Contribution margin after ads | $7,649,916.69 |
| B16 | Ratio before ads | 44.62% |
| B17 | Ratio after ads | 20.52% |
| B18 | Average order value | $74.42 |
| B19 | Margin after ads per order | $15.27 |
| B20 | Break-even revenue per ad dollar | 2.24 |
| B21 | Actual revenue per ad dollar | 4.15 |
The example store's own 90 day figure for contribution margin after ads is $7,649,916.70, or 20.52%, in the same example figures. The sheet lands one cent away, which is rounding. If your B15 is off by more than that, a formula is pointing at the wrong cell.
How do you know your sheet is right?
Run three checks before you put your own numbers in.
- It reproduces the example above to within a cent.
- B16 minus ad spend as a share of revenue equals B17. In the example, 44.62% less 24.10% is 20.52%.
- Set B8 to zero. B15 should equal B14, and B21 should read "not enough data".
Then read B20 against B21. B20 is the revenue each ad dollar must bring in for the order to cover its own variable costs. B21 is what the period delivered across all revenue. In the example data the sheet shows 4.15 against a break-even of 2.24. That blended figure counts every order, including ones no ad touched, so it flatters the ads. The break-even ROAS guide covers the difference.
Which what-ifs are worth running first?
Change one input at a time and watch B15 and B17. Here are three cases run on the example figures, by my arithmetic, not customer results.
| Change | Input edited | Margin after ads | Ratio after ads |
|---|---|---|---|
| None | $7,649,916.69 | 20.52% | |
| Shipping costs $1 more per order | B5 to $8.50 | $7,148,929.69 | 19.17% |
| Card rate of 2.5% | B6 to 2.5% | $7,799,058.04 | 20.92% |
| Order value 10% lower, same orders and ads | B2 to $33,556,804.54 | $5,595,494.54 | 16.67% |
One dollar of shipping across 500,987 orders is $500,987, more than three times the $149,141 saved by the lower card rate. The last row is the one to study. Revenue fell 10% and margin after ads fell 27%, because orders, shipping and ad spend all stayed where they were. The per order worksheet shows the same effect on a single order.
How do you decide whether to raise Meta ad spend without hurting margin?
Raise it only if each extra ad dollar brings in more new revenue than B20, the break-even revenue per ad dollar. In the example data that is 2.24. The sheet's B21 of 4.15 is the wrong figure to judge by, because it spreads all revenue over all spend, including orders no ad touched. A new dollar of spend earns only the revenue it adds.
Here is what an extra Meta dollar does to margin after ads, using the example store's 90 day figures, with order value held where it is. It is my arithmetic, not a customer result.
| New revenue per extra ad dollar | Margin after ads per extra dollar |
|---|---|
| 2.00 | -$0.11 |
| 2.24 | $0.00 |
| 3.00 | +$0.34 |
A 10% rise in ad spend makes this concrete. Set B8 to $9,885,266.78 and leave revenue alone. B15 drops from $7,649,916.69 to $6,751,256.07 and B17 from 20.52% to 18.11%. To hold B15 where it was, the extra $898,660.62 of spend has to bring in $2,014,054.59 of new revenue, which is 5.4% more than the 90 days produced.
So the order of work is this:
- Raise spend in small steps, not one jump.
- Compare the same number of days before and after.
- Judge the move by B15 in dollars first, then B17. A falling ratio can still hold more dollars, and dollars pay the fixed costs.
- Count only revenue the extra spend plausibly added. Tracked revenue from a platform that grades its own ads is a claim, not proof of new orders.
The sheet cannot tell you what the next dollar will earn. It tells you the bar the next dollar has to clear.
What did the example sheet show beyond the headline?
Two things the totals hide. Both are my arithmetic on the 90 day example data, not customer results.
First, where each average order's money goes. Of the $74.42 average order value, product cost takes $31.26, shipping $7.50, payment fees $2.46 and ads $17.94, leaving $15.27. The figures are rounded one by one, so they can differ from the total by a cent. Ads take $17.94 of each order, more than shipping and card fees combined at $9.96.
Second, how much room there was. B14, margin before ads, was $16,636,522.85. That is the most the brand could have spent on ads and still broken even, and it is 1.85 times the $8,986,606.16 it did spend. In the same data a one point error in B4 moves B15 by $372,853.38, or 4.9% of the $7,649,916.69. Check product cost first.
What can a spreadsheet version not do?
It cannot keep itself current. The sheet is right on the day you fill it in.
One product cost percentage hides the spread between products. One ad spend cell hides which channel earned its money. And nothing in a sheet warns you when the store's revenue and the ad platform's claimed revenue stop agreeing, which is when the inputs themselves need checking.
For a monthly review, that is fine. Copy the tab each month and you have the trend table described in the contribution margin ratio article. For daily decisions across several channels, the typing becomes the job. That is the kind of work covered in AI for ecommerce and AI agents for ecommerce.
Gross margin, in B11, is a different number from the one in B14. The contribution margin vs gross margin comparison explains when to quote each.
Where Cosmic AI fits
Cosmic AI is the product I build. It does this calculation from your own store and ad data once your costs are set, checks the sources against each other first, and answers "not enough data" when a cost is missing, the same rule as the formulas above. Every connection starts at Read only, and you decide per connection whether agents only read, ask first, or act on their own. The product page and pricing have the detail.
Frequently asked questions
What is the formula for calculating contribution margin?
Contribution margin is net revenue minus variable costs. In the sheet above that is gross margin less shipping and payment fees for the figure before ads, and less ad spend as well for the figure after ads.
How do I calculate a 20% margin?
Divide your cost by 0.80. An item that costs $80 must sell for $100 to leave a 20% margin, because the $20 of profit is 20% of the $100 price. Adding 20% to cost gives $96, which is only a 16.7% margin.
What is a 50% margin on $10?
If $10 is the selling price, a 50% margin means $5 of profit and $5 of cost. If $10 is the cost, a 50% margin needs a $20 price. Margin is always a share of the price, never of the cost.
How do you calculate contribution?
Take the revenue from a sale and subtract the costs that exist only because of that sale: the product, shipping, the payment fee and the ad. The remainder is the sale's contribution toward fixed costs and profit.