How to calculate a weighted average in Excel with SUMPRODUCT and SUM, worked on six customers' gross margins weighted by revenue. It shows why AVERAGE gives the wrong figure, the helper-column version, the check against total gross profit, and a weighted average by segment with a condition.
A weighted average in Excel is =SUMPRODUCT(values, weights)/SUM(weights): multiply each value by its weight, add the products, and divide by the total weight. Excel has no AVERAGE.WEIGHTED function, so SUMPRODUCT is the standard way. On six customers below, the simple average margin is 25.0% and the revenue-weighted margin, the one that describes the business, is 21.17%.
Weighted average = Σ (value × weight) / Σ weight
In Excel:
=SUMPRODUCT(values, weights)/SUM(weights)
SUMPRODUCT multiplies the two ranges row by row and returns the sum of the products. Dividing by the sum of the weights turns that total back into an average. The weights can be any positive numbers, such as revenue in dollars; they do not need to add up to 100%.
Google Sheets has a ready-made AVERAGE.WEIGHTED function. Excel does not, so a workbook built in Sheets with that function shows #NAME? when opened in Excel. SUMPRODUCT works in both.
Revenue for the year in column B, gross margin in column C (stored as a percentage, so 18% is the number 0.18), and segment in column D. Rows 2 to 7:
| Customer | Revenue (USD) | Gross margin | Segment |
|---|---|---|---|
| A | 400,000 | 18% | Enterprise |
| B | 90,000 | 25% | Mid-market |
| C | 12,000 | 30% | Mid-market |
| D | 250,000 | 22% | Enterprise |
| E | 60,000 | 35% | Mid-market |
| F | 188,000 | 20% | Enterprise |
| Total | 1,000,000 |
Customers A, B and C are the same three accounts as in gross margin vs contribution margin vs net margin, where their margins are built up line by line. The per-account figures come from margin by account.
=AVERAGE(C2:C7)
This returns 25.0%: the six margins add to 150 percentage points, and 150 / 6 = 25.0. Every customer counts once, so customer C, with $12,000 of revenue, moves the result as much as customer A, with $400,000.
That is the wrong figure for any question about the business as a whole. The question "what margin do we make across these customers?" means total gross profit over total revenue, and the small, high-margin accounts pull the simple average up. The general principle, count-weighted against value-weighted, is in count-weighted and value-weighted measures.
=SUMPRODUCT(B2:B7,C2:C7)/SUM(B2:B7)
This returns 21.17%. To see each product, add a helper column E with =B2*C2, fill it down to row 7, and divide its total by total revenue:
=SUM(E2:E7)/SUM(B2:B7)
| Customer | Revenue (USD) | Gross margin | Revenue × margin (USD) |
|---|---|---|---|
| A | 400,000 | 18% | 72,000 |
| B | 90,000 | 25% | 22,500 |
| C | 12,000 | 30% | 3,600 |
| D | 250,000 | 22% | 55,000 |
| E | 60,000 | 35% | 21,000 |
| F | 188,000 | 20% | 37,600 |
| Total | 1,000,000 | 21.17% | 211,700 |
Revenue × margin is each customer's gross profit in dollars. The products add to $211,700, and $211,700 / $1,000,000 = 21.17%. The weighted average is 3.83 points below the simple one, because the three largest customers, A, D and F, have the three lowest margins.
A revenue-weighted margin, multiplied by total revenue, must return total gross profit:
21.17% × $1,000,000 = $211,700
In the sheet, the weighted margin times SUM(B2:B7) must equal =SUM(E2:E7), the total of the helper column: both are 211,700. Run the same test on the simple average and it fails: 25.0% × $1,000,000 = $250,000, which is $38,300 of gross profit that does not exist. A weighted average that describes a total must rebuild that total; one that cannot is weighted by the wrong thing.
The same identity sits behind the company figure in gross profit margin: total gross profit over total revenue is the line margins weighted by revenue share.
For one segment only, put the condition inside SUMPRODUCT as a TRUE/FALSE term, and divide by the segment's revenue with SUMIFS:
=SUMPRODUCT((D2:D7="Enterprise")*B2:B7*C2:C7)/SUMIFS(B2:B7,D2:D7,"Enterprise")
(D2:D7="Enterprise") returns TRUE or FALSE per row, and multiplying turns those into 1 and 0, so only Enterprise rows reach the sum. The SUMIFS argument order is covered in SUMIF and SUMIFS in Excel.
| Segment | Revenue (USD) | Gross profit (USD) | Weighted margin |
|---|---|---|---|
| Enterprise (A, D, F) | 838,000 | 164,600 | 19.64% |
| Mid-market (B, C, E) | 162,000 | 47,100 | 29.07% |
| Total | 1,000,000 | 211,700 | 21.17% |
Enterprise: 164,600 / 838,000 = 19.64%. Mid-market: 47,100 / 162,000 = 29.07%. Weight the two segment margins by their revenue and you get 21.17% again, because the segment gross profits add back to $211,700. That recombination is the second check: segments must rebuild the company figure.
=SUMPRODUCT(units,price)/SUM(units), which equals revenue over units.=SUMPRODUCT(B2:B7,C2:C8) returns #VALUE!.=COUNT(B2:B7) equals the number of rows.Covirage always weights by the right base, computing totals from the underlying rows rather than averaging percentages, and the tools check that the segment figures recombine to the company figure; the external AI model explains the result and never does the arithmetic. See margin per customer from your ledger, with the weighted total and the accounts that pull it down, in customer profitability. For the simple average, median and spread beside it, see descriptive statistics in Excel.
No dedicated function. Use =SUMPRODUCT(values,weights)/SUM(weights). Google Sheets has AVERAGE.WEIGHTED, but it does not exist in Excel, so a sheet using it shows an error when opened in Excel.
Whenever the items differ in size and the answer should describe the total, such as margin across customers, price across orders or days to pay across invoices. Use a simple average only when every item should count equally.
Multiply each percentage by its weight in dollars or units, sum the products and divide by the total weight. For margins weighted by revenue this gives total gross profit divided by total revenue.
Yes. Weights can be any positive numbers, such as revenue amounts. The formula divides by their sum, which normalizes them. Weights only need to sum to one if you skip the division.