ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. Weighted Average With Criteria in Excel Using SUMPRODUCT

Weighted Average With Criteria in Excel Using SUMPRODUCT

By ExcelReady Team·Updated November 3, 2026·6 min read

The short answer

For a weighted average with criteria in Excel, multiply the condition, the values and the weights inside SUMPRODUCT, then divide by the matching weights: =SUMPRODUCT((A2:A8="East")C2:C8D2:D8)/SUMIF(A2:A8,"East",D2:D8). The condition turns non-matching rows into zeros. For two conditions, multiply a second test and divide by SUMIFS.

Key takeaways

  • Weighted average with a condition = SUMPRODUCT(condition × values × weights) ÷ SUM of the matching weights.
  • The condition in brackets gives TRUE or FALSE, and multiplying turns them into 1 and 0.
  • Divide by SUMIF or SUMIFS of the weights, using exactly the same condition as the top line.
  • AVERAGEIF gives a simple average, not a weighted one, so it gives the wrong answer here.
  • Wrap the formula in IFERROR to handle groups with no matching rows.
On this page+
  1. What is a weighted average with criteria?
  2. How to calculate a weighted average with one condition
  3. Why AVERAGEIF gives the wrong answer
  4. How to use two or more conditions
  5. The comma version with the double negative
  6. A helper column version with SUMIFS only
  7. Common mistakes and #DIV/0!
  8. Practise it

A weighted average with criteria in Excel answers questions like "what was the average price we got in the East region, counting each sale by how many units it moved?" A plain weighted average uses every row. Adding a condition means only the matching rows count, in both the top and the bottom of the calculation. SUMPRODUCT handles the top, and SUMIF or SUMIFS handles the bottom. This guide is for analysts, finance staff and anyone preparing for an Excel test.

All the examples use this sales table in A1:D8:

ABCD
1RegionChannelPriceUnits
2EastOnline10100
3WestStore1250
4EastStore8300
5WestOnline9200
6EastOnline1540
7NorthStore11120
8WestStore1480

What is a weighted average with criteria?#

A weighted average gives each value an importance, called its weight. Here the values are prices and the weights are units: a sale of 300 units should count more than a sale of 40. The formula is:

weighted average = sum of (value × weight) ÷ sum of weights

"With criteria" means you only include rows that meet a condition, such as Region = East. If weighted averages are new to you, start with the guide to how to calculate a weighted average, which covers the version without conditions.

How to calculate a weighted average with one condition#

Put the condition inside SUMPRODUCT, and divide by SUMIF of the weights with the same condition:

Excel formula
=SUMPRODUCT((A2:A8="East")*C2:C8*D2:D8)/SUMIF(A2:A8,"East",D2:D8)

The result is 9.09 (to two decimal places). Here is how it works, part by part:

  1. (A2:A8="East") tests every row and returns TRUE or FALSE: TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE.
  2. Multiplying turns TRUE into 1 and FALSE into 0, so non-East rows become zero.
  3. C2:C8*D2:D8 is price × units for each row. Only the East rows survive: 1,000 + 2,400 + 600 = 4,000.
  4. SUMIF(A2:A8,"East",D2:D8) adds the East units: 100 + 300 + 40 = 440.
  5. 4,000 ÷ 440 = 9.0909…

The SUMPRODUCT function guide explains how it multiplies ranges row by row, and the article on SUMPRODUCT with examples shows other uses. To use a cell instead of typing "East", put the region in F2 and write (A2:A8=F2) and SUMIF(A2:A8,F2,D2:D8).

Why AVERAGEIF gives the wrong answer#

AVERAGEIF gives every matching row the same weight, so it ignores how many units each sale moved:

Excel formula
=AVERAGEIF(A2:A8,"East",C2:C8)

This returns 11: (10 + 8 + 15) ÷ 3. But most East units sold at 8, so the true average price per unit is 9.09. The simple average is pulled up by the small sale at 15. Use AVERAGEIF when every row should count equally, as in the guide to averages by group; use the weighted formula when rows have different sizes.

How to use two or more conditions#

For two conditions, multiply a second test inside SUMPRODUCT and switch the bottom line to SUMIFS. For East and Online:

Excel formula
=SUMPRODUCT((A2:A8="East")*(B2:B8="Online")*C2:C8*D2:D8)/SUMIFS(D2:D8,A2:A8,"East",B2:B8,"Online")

Only rows 2 and 6 match. The top line is 1,000 + 600 = 1,600, the bottom is 100 + 40 = 140, and the result is 11.43. Each extra condition is one more bracket in SUMPRODUCT and one more range/criteria pair in SUMIFS. The guide to COUNTIFS and SUMIFS and the SUMIFS function guide explain the pairs.

For OR logic, such as East or West, add the tests instead of multiplying them:

Excel formula
=SUMPRODUCT(((A2:A8="East")+(A2:A8="West"))*C2:C8*D2:D8)/(SUMIF(A2:A8,"East",D2:D8)+SUMIF(A2:A8,"West",D2:D8))

This returns 9.77 (7,520 ÷ 770). Adding works here because a row can't be both East and West, so no row is counted twice.

The comma version with the double negative#

You can also give SUMPRODUCT separate arguments, but then the condition needs a double negative:

Excel formula
=SUMPRODUCT(--(A2:A8="East"),C2:C8,D2:D8)/SUMIF(A2:A8,"East",D2:D8)

This also returns 9.09. SUMPRODUCT treats TRUE and FALSE as zero when they are passed as their own argument, so without -- the top line would be 0. The two minus signs turn TRUE and FALSE into 1 and 0. The article on the double negative in Excel explains why. The multiply version above avoids the issue, which is why many people prefer it.

A helper column version with SUMIFS only#

If SUMPRODUCT feels hard to read, add a helper column and use SUMIFS twice. In E2, type =C2*D2 and fill down to get revenue for each row. Then:

Excel formula
=SUMIFS(E2:E8,A2:A8,"East")/SUMIFS(D2:D8,A2:A8,"East")

This gives the same 9.09: East revenue (4,000) divided by East units (440). Helper columns make each step visible, which helps when someone else checks your file. The same idea works in a pivot table: put revenue and units in the source, then add a calculated field of =Revenue/Units. The pivot sums both before dividing, so each group shows its weighted average.

Common mistakes and #DIV/0!#

Most wrong answers come from a mismatch between the top and bottom of the formula. Check these:

  1. Different conditions on top and bottom. If the top filters East and Online but the bottom only East, the result is too small. Use the same conditions in both.
  2. Dividing by the count instead of the weights. COUNTIF gives the number of rows, not the total units. Divide by SUMIF of the weight column.
  3. Ranges of different sizes. Every range in SUMPRODUCT must cover the same rows, or Excel returns an error such as #VALUE! or #N/A.
  4. No matching rows. The weights add up to zero and Excel shows #DIV/0!. Wrap it: =IFERROR(SUMPRODUCT(…)/SUMIF(…),"").
  5. Weights stored as text. SUMIF skips numbers stored as text, so the bottom line comes out too small while the multiplication on top may still use them. Convert them to real numbers with VALUE.

Practise it#

This formula combines conditional totals with multiplication across ranges. Practise SUMIF in a live spreadsheet for the bottom line, then practise COUNTIFS and SUMIFS for the multi-condition version. Each lesson checks your formula as soon as you type it. Then try the exercise on this page to find the weighted average price for the East region.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

What is the average price per unit for the East region, weighted by units sold? In G2, type =SUMPRODUCT((A2:A8="East")*C2:C8*D2:D8)/SUMIF(A2:A8,"East",D2:D8).

fx
ABCDEFGH
1
Region
Channel
Price
Units
2
East
Online
10
100
East avg price
3
West
Store
12
50
4
East
Store
8
300
5
West
Online
9
200
6
East
Online
15
40
7
North
Store
11
120
8
West
Store
14
80
9
10
11

Tip: The top line adds price × units for the East rows (4,000). SUMIF adds the East units (440). The answer is about 9.09.

Practise this in a lesson

LessonCOUNTIFS and SUMIFSCount and sum with several conditions at once, and learn why SUMIFS puts the sum range first.LessonSUMIFAdd up only the numbers that meet a condition, with and without a separate sum range.Function guideSUMPRODUCTMultiply columns and add the results in one step with SUMPRODUCT. Totals, weighted averages, conditions, and a live exercise to try.Function guideSUMIFSTotal values that meet several conditions with SUMIFS. Examples by region, month and number range, common errors, and live practice.

Frequently asked questions

How do I calculate a weighted average with criteria in Excel?

+

Use =SUMPRODUCT((criteria_range="East")valuesweights)/SUMIF(criteria_range,"East",weights). The top line adds value times weight for matching rows only, and the bottom line adds the matching weights.

Can AVERAGEIF calculate a weighted average?

+

No. AVERAGEIF and AVERAGEIFS give every matching row the same importance. For a weighted average, use SUMPRODUCT for the weighted total and SUMIF or SUMIFS for the weights.

How do I do a weighted average with two criteria?

+

Multiply two conditions inside SUMPRODUCT and use SUMIFS for the weights: =SUMPRODUCT((A2:A8="East")*(B2:B8="Online")C2:C8D2:D8)/SUMIFS(D2:D8,A2:A8,"East",B2:B8,"Online").

Why does my weighted average formula return #DIV/0!?

+

No rows match the condition, so the total weight is zero. Check the spelling of the criteria, or wrap the formula in IFERROR to show a blank or a message instead.

Can I calculate a weighted average with criteria in a pivot table?

+

Yes. Add a helper column for value times weight, then create a calculated field that divides that column by the weight. The pivot sums both before dividing, which gives the weighted average for each group.

Sources

  • SUMPRODUCT function - Microsoft Support
  • SUMIFS function - Microsoft Support
  • SUMIF function - Microsoft Support

Written and checked by the ExcelReady Team. First published November 3, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What is a weighted average with criteria?
  2. How to calculate a weighted average with one condition
  3. Why AVERAGEIF gives the wrong answer
  4. How to use two or more conditions
  5. The comma version with the double negative
  6. A helper column version with SUMIFS only
  7. Common mistakes and #DIV/0!
  8. Practise it

Keep reading

Math· 6 min read

How to Calculate a Weighted Average in Excel

To calculate a weighted average in Excel, multiply each value by its weight, add the results, and divide by the total of the weights: =SUMPRODUCT(B2:B5,C2:C5)/SUM(C2:C5). B2:B5 holds the values and C2:C5 the weights. Dividing by SUM keeps the answer right even when the weights don't add up to 100%.

Math· 6 min read

SUMPRODUCT in Excel: Multiply and Add in One Step

SUMPRODUCT multiplies matching items in two or more ranges and adds up the results. =SUMPRODUCT(C2:C7,D2:D7) multiplies each quantity by its price and returns the total, with no helper column. It also handles conditions, such as =SUMPRODUCT((B2:B7="North")*C2:C7*D2:D7), and works in every version of Excel.

Conditional math· 7 min read

COUNTIFS and SUMIFS: Multiple Conditions in Excel

COUNTIFS counts rows that meet several conditions, and SUMIFS adds numbers from those rows. Each condition is a pair: a range, then its criteria. A row counts only if it matches every pair. SUMIFS puts the sum range first: =SUMIFS(E2:E9,A2:A9,"North",C2:C9,"Laptop") totals North laptop revenue.

More on conditional math

  • Excel Wildcards: *, ? and ~ in COUNTIF and SUMIF
  • How to Calculate an Average by Group in Excel
  • AVERAGEIF and AVERAGEIFS in Excel
  • AVERAGEIFS in Excel: Averages With Several Conditions
  • Count Cells Above Average in Excel With COUNTIF
  • How to Count by Category in Excel
All conditional math articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free