Roll a transaction log up into profit by product. SUMIFS totals revenue and cost for each product, and the difference is its profit — the foundation of any product P&L.
The example
Profit for Widget from a sales log.
| A | B | C | |
|---|---|---|---|
| 1 | Product | Revenue | Profit |
| 2 | Widget | $4,000 | $1,500 |
| 3 | Gadget | $6,000 | $2,100 |
The formula
Profit per product from the log:
How it works
Two conditional sums, then subtract:
SUMIFS(revenue, product, name)totals all revenue rows for that product.- Do the same for cost, then subtract for profit.
- Put the product name in a cell and reference it so the formula fills down into a per-product table.
- Add a margin % column:
=profit / revenue.
Computed profit per row? If profit isn’t a column, compute it inline with SUMPRODUCT: =SUMPRODUCT((prod=A2)*(rev-cost)) totals (revenue−cost) for the product in one shot.
Try it: interactive demo
Log lines as “product,revenue,cost”; pick a product.
Variations
Margin %
Profit over revenue:
Inline (SUMPRODUCT)
No profit column needed:
Top product
Best profit:
Pitfalls & errors
Exact product keys. SUMIFS matches text exactly (case-insensitive) — trailing spaces or typos split a product into two.
Align the ranges. The criteria range and sum range must be the same size and orientation.
Profit needs both sides. Make sure every revenue row has a matching cost basis, or profit is overstated.
Practice workbook
Frequently asked questions
How do I calculate profit by product in Excel?
How do I get profit without a profit column?
How do I add a margin percentage?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class