How to Calculate Cost per Unit in Excel
By ExcelReady TeamUpdated 7 min read
The short answer
To calculate cost per unit in Excel, divide the total cost by the number of units: =B2/C2. Add every cost before dividing, such as =(B2+C2)/D2 for purchase plus shipping. Wrap it in ROUND for clean prices, =ROUND((B2+C2)/D2,2), and use IFERROR or IF to avoid #DIV/0! when units are zero.
Key takeaways
- Cost per unit is total cost divided by units: =B2/C2.
- Add all costs first, then divide: =(B2+C2)/D2. Brackets make Excel add before it divides.
- Use =ROUND(B2/C2,2) to store the result to cents, and IFERROR to hide #DIV/0! for zero units.
- For an average across batches, divide total cost by total units. Don't average the unit costs.
On this page+
- The basic cost per unit formula
- How to include shipping and other costs
- How to round cost per unit to cents
- How to avoid #DIV/0! when units are zero
- How to find the average cost per unit across purchases
- How to include fixed costs
- Using cost per unit in other calculations
- Common cost per unit mistakes
- Practise it
To calculate cost per unit in Excel, divide the total cost by the number of units. The formula is one line, =B2/C2, but real costs add a few twists: shipping and fees, rounding to cents, zero quantities, and averages across several purchases. This guide covers each one with a small product table, so you can price stock, compare suppliers or answer a test question with confidence.
The basic cost per unit formula#
Cost per unit is the total cost divided by the number of units:
=B2/C2If you paid 2,380 for 720 mugs, =2380/720 gives about 3.31 per mug. Use cell references instead of typing the numbers, so the result updates when the data changes. Then fill the formula down the column (Windows: Ctrl+D; Mac: ⌘D) and each row divides its own cost by its own units.
Every formula starts with =, and Excel's division sign is the forward slash /. If those are new to you, the first formulas lesson is the place to start.
How to include shipping and other costs#
The true cost of a product, often called the landed cost, includes everything you paid to get it: purchase price, shipping, import duty and fees. Add them together before dividing:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Product | Purchase cost | Shipping | Units | Cost per unit |
| 2 | Mugs | 2,380 | 215 | 720 | 3.60 |
| 3 | Tote bags | 1,560 | 140 | 450 | 3.78 |
| 4 | Pens | 640 | 58 | 1,000 | 0.70 |
| 5 | Notebooks | 1,850 | 145 | 640 | 3.12 |
In E2:
=(B2+C2)/D2For the mugs, (2,380 + 215) / 720 = 2,595 / 720 = 3.604... The brackets matter. Without them, =B2+C2/D2 divides only the shipping by the units and then adds the full purchase cost, giving 2,380.30, which is clearly wrong. Excel does multiplication and division before addition and subtraction, so use brackets whenever you add costs first.
If you have many cost columns, use SUM: =SUM(B2:C2)/D2.
How to round cost per unit to cents#
Use ROUND to store the result to two decimal places:
=ROUND((B2+C2)/D2,2)The 2 means two decimal places, so 3.604... becomes 3.60. For the tote bags, 1,700 / 450 = 3.777... rounds to 3.78.
Rounding is not the same as formatting. A cell formatted to show two decimals still holds 3.604166..., and later calculations use that full value. That's fine for reports, but if you're setting prices or matching an invoice, ROUND makes the stored value match what you see. If you must never under-price, use ROUNDUP instead: =ROUNDUP((B2+C2)/D2,2) gives 3.61. The ROUND function guide and the guide to ROUND, ROUNDUP and ROUNDDOWN explain the differences.
How to avoid #DIV/0! when units are zero#
If the units cell is 0 or empty, the formula returns #DIV/0!, because nothing can be divided by zero. This happens with new products, cancelled orders or rows waiting for data. Two fixes:
=IFERROR(ROUND((B2+C2)/D2,2),"")
=IF(D2=0,"",ROUND((B2+C2)/D2,2))The first shows a blank for any error. The second checks the units directly, so other mistakes, such as text in a cost cell, still show up. When you're cleaning up someone else's sheet, the IF version is safer because it doesn't hide problems. The IFERROR function guide and how to fix #DIV/0! cover more cases.
How to find the average cost per unit across purchases#
When you buy the same item several times at different prices, the average cost per unit is total cost divided by total units. Don't average the unit costs.
| Batch | Units | Total cost | Cost per unit |
|---|---|---|---|
| March | 400 | 1,000 | 2.50 |
| April | 100 | 350 | 3.50 |
| May | 500 | 1,150 | 2.30 |
With units in B2:B4 and costs in C2:C4:
=SUM(C2:C4)/SUM(B2:B4)This gives 2,500 / 1,000 = 2.50. If you used =AVERAGE(D2:D4) instead, you'd get 2.77, because the small April batch counts as much as the big May batch. That's a weighted average problem; the guide to weighted averages in Excel shows the SUMPRODUCT method too.
How to include fixed costs#
Some costs don't change with volume, such as rent or a machine lease. Spread the fixed cost across the units, then add the variable cost of each unit:
=Fixed/Units+VariableWith a fixed cost of 3,000 a month and a variable cost of 4.20 per unit:
| Units made | Fixed cost per unit | Total cost per unit |
|---|---|---|
| 500 | 6.00 | 10.20 |
| 1,500 | 2.00 | 6.20 |
| 3,000 | 1.00 | 5.20 |
Put the fixed and variable costs in their own cells and lock them with $ signs, such as =$G$1/A2+$G$2, so you can fill the formula down a list of unit counts. The more you make, the lower the cost per unit, which is why break-even and pricing models start here.
Using cost per unit in other calculations#
Cost per unit feeds straight into the numbers managers ask for:
- Profit per unit: price minus cost per unit, such as
=F2-E2. - Margin: profit per unit divided by price,
=(F2-E2)/F2. The guide to the profit margin formula covers margin vs markup. - Other per-unit measures: price per square foot, cost per hire or cost per click all use the same division. The guide to calculating ratios shows how to present them.
The real estate case study practises exactly this idea with price per square foot, a common task in analyst tests.
Common cost per unit mistakes#
Most wrong answers come from the order of the maths or the data, not the division itself:
- Dividing the wrong way round. Units divided by cost gives units per dollar, not cost per unit. The cost always goes on top.
- Missing brackets.
=B2+C2/D2divides only the shipping. Write=(B2+C2)/D2. - Averaging unit costs across batches. Divide total cost by total units instead.
- Units stored as text. Imported quantities can be text, which gives #VALUE! or wrong totals. Convert them to numbers first.
- Rounding too early. Round the final cost per unit, not each cost before you add them, or small errors add up.
Practise it#
Try the exercise on this page: work out a landed cost per unit and round it to cents. Then practise ROUND, ROUNDUP and ROUNDDOWN in a live spreadsheet, and put per-unit maths to work in the real estate case study, where you calculate price per square foot like an analyst. Each step is checked as you type.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
Find the landed cost per unit for the mugs: purchase cost plus shipping, divided by units, rounded to cents. In E2, type =ROUND((B2+C2)/D2,2) and press Enter.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Cost per unit | |||||
| 2 | ||||||
| 3 | ||||||
| 4 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 8 |
Tip: Add the purchase cost and shipping in brackets (2,595), divide by 720 units (3.6041...), then round to 2 decimals: 3.6.
Practise this in a lesson
Frequently asked questions
What is the formula for cost per unit in Excel?
Divide total cost by the number of units, for example =B2/C2. If the costs are in more than one column, add them in brackets first: =(B2+C2)/D2.
How do I round cost per unit to two decimal places?
Wrap the formula in ROUND: =ROUND(B2/C2,2). This stores the value to cents. Changing the number format only changes what you see, not the value used in later calculations.
How do I stop #DIV/0! in a cost per unit formula?
The error means the units cell is zero or empty. Use =IFERROR(B2/C2,"") to show a blank, or =IF(C2=0,"",B2/C2) to test the units directly.
How do I calculate average cost per unit across several purchases?
Divide the total cost by the total units: =SUM(B2:B4)/SUM(C2:C4). Averaging the unit costs with AVERAGE gives the wrong answer when the purchases have different quantities.
How do I include fixed costs in cost per unit?
Spread the fixed cost over the units and add the variable cost: =Fixed/Units+Variable. The more units you make, the lower the cost per unit, because the fixed cost is shared by more units.