Tabellab

SUMPRODUCT Basics: Weighted Totals and True Averages

Lesson 1 of 20Lab

All lessons
  1. SUMPRODUCT Basics: Weighted Totals and True AveragesLabFree
  2. Conditions as 1s and 0s: (range="x")*1 and the Double Unary --Lab Locked
  3. AND vs OR Logic in Arrays: Multiply, Add and the SIGN TrickLab Locked
  4. Counting with Multiple Criteria and Partial Text: ISNUMBER(SEARCH())Lab Locked
  5. Distinct Counts with SUMPRODUCT(1/COUNTIF)Lab Locked
  6. Two-Way Conditional Sums: Row and Column Criteria in One FormulaLab Locked
  7. Array MAX and MIN with Conditions, and MATCH(MAX(…)) Position LookupsLab Locked
  8. Mid-Course Project: A Weighted Supplier Scorecard with a Ranked ChartLab Locked
  9. Date Conditions in Arrays: Month, Weekday and Quarter Tests That SUMIFS Cannot DoLab Locked
  10. Two-Key Number Lookups with SUMPRODUCT – and the Missing and Duplicate Key TrapsLab Locked
  11. Ranks with SUMPRODUCT: Overall, Within a Group, Unique Tie-Breaks and Top-N TotalsLab Locked
  12. Size Bands with SUMPRODUCT: Counts, Totals and Rates per Band, and a HistogramLab Locked
  13. Row-Wise ANY and ALL Tests over a Block: Counting Products with MMULTLab Locked
  14. Price vs Volume Effects: Splitting a Revenue Change with SUMPRODUCT and a Bridge ChartLab Locked
  15. Arrays on Messy Data: Numbers Stored as Text, the Comma-Style Trap and a Reconciliation CheckLab Locked
  16. Project: A Quarterly Order-Book Dashboard Built with SUMPRODUCTLab Locked
  17. Pareto Without Sorting: Cumulative Shares and ABC Classes with SUMPRODUCT (with Chart)Lab Locked
  18. Tiered Rebates with SUMPRODUCT: Progressive Tiers vs All-Units and the Threshold Cliff (with Chart)Lab Locked
  19. Blend Recipes as a Matrix: Cost per Kilo, Green Coffee Needed and Shortages with SUMPRODUCT and MMULT (with Chart)Lab Locked
  20. Final Project: Account Profitability Dashboard – Revenue, Cost of Goods, Rebates and Cost-to-Serve from Raw Orders (with Chart)Lab Locked

You are not signed in — the lab works, but your progress is not saved. Sign up

Lesson 1 of 20 is free. Unlock all 20 hands-on labs, the final exam and your certificate.

Buy course — $9.90
Loading the spreadsheet…

Why SUMPRODUCT is the formula analysts reach for first

If you have ever added a helper column just to multiply two numbers on every row, and then summed that column, this lesson is for you. SUMPRODUCT does both steps in one cell. It is one of the oldest functions in Excel, it works in every version from Excel 2007 to Microsoft 365, in Google Sheets and in LibreOffice, and it quietly powers a large share of the dashboards, price lists and scorecards you see in finance, sales and operations teams.

The lesson uses Tidewell Coffee Roasters, a fictional wholesale roastery. Its Q3 order book has 20 product lines with bags ordered, price per bag, bag size in kg, cost per kg and a cupping score. Nobody built line totals, and two questions keep coming back from the owner: what is this order book worth, and what does an average bag really cost us? The second question sounds trivial, yet the obvious answer, a plain AVERAGE of the price column, is off by about 25 percent. By the end of this article you will know why, and you will be able to prove it with a single formula.

This is the free first lesson of a course on SUMPRODUCT and array formulas. Everything here is practical: you can follow along in the interactive lab above, where the same 20 lines are waiting for your formulas, or in your own copy of Excel.

The core idea: multiply row by row, then add

SUMPRODUCT(array1, [array2], [array3], …) takes two or more ranges of the same shape, multiplies the first cell of each range together, then the second cells, then the third, and finally adds all those products. With =SUMPRODUCT(B2:B21,C2:C21) Excel calculates 120 × 21.40 + 95 × 19.90 + 80 × 19.50 and so on for all 20 rows. That is exactly bags × price per line, summed: the value of the order book.

=SUMPRODUCT(B2:B21, C2:C21)Bags (B)Price (C)Row product120×21.40=2,568.0095×19.90=1,890.5080×19.50=1,560.0060×24.80=1,488.00… and 16 more rows, down to row 21SUM16,709.10One cell replaces a helper column of 20 line totals plus a SUM. No Ctrl+Shift+Enter needed.
How SUMPRODUCT works: each row of the bags range is multiplied by the same row of the price range, and the row products are added into one result.

Three properties make the function so useful. First, you can pass up to 255 arrays, so bags × kg per bag × cost per kg is just one more argument. Second, SUMPRODUCT evaluates arrays natively, so you never need the old Ctrl+Shift+Enter keystroke that classic array formulas required. Third, non-numeric entries such as text or blanks are treated as zero, so a stray label in a range does not crash the formula (although it can silently hide a value, more on that under common mistakes).

The one hard rule: every array must have the same number of rows and columns. =SUMPRODUCT(B2:B21,C2:C20) returns #VALUE! because one range has 20 cells and the other 19. That error is actually helpful, because it tells you immediately that your ranges are misaligned instead of returning a plausible but wrong number.

Weighted averages: the second superpower

A plain AVERAGE gives every row the same vote. That is fine when every row is equally important, such as the average temperature over 20 days. It is wrong when rows carry different weights, such as products sold in very different quantities. A weighted average lets each value count in proportion to its weight:

Weighted average = SUMPRODUCT(values, weights) / SUM(weights)

For Tidewell, the value is the price per bag and the weight is the number of bags. The top of the fraction, SUMPRODUCT(B2:B21,C2:C21), is the order value. The bottom, SUM(B2:B21), is the total number of bags. Order value divided by bags sold is, by definition, the average revenue per bag. That is the number a forecast needs.

When the weight is itself a product of two columns, the bottom of the fraction must use the same product. A cupping score weighted by kilos of coffee uses bags × kg per bag as the weight, so the formula is =SUMPRODUCT(B2:B21,D2:D21,F2:F21)/SUMPRODUCT(B2:B21,D2:D21). If you divide by SUM(B2:B21) instead, the top is measured in kilos and the bottom in bags, and the result is meaningless.

Worked example: Tidewell’s Q3 order book

Here is the complete order book from the lab, with the two numbers SUMPRODUCT calculates internally shown as extra columns so you can see what is going on. In the real sheet those columns do not exist; that is the point of the function.

ProductBagsPrice/bagkg/bagCost/kgBags × priceBags × kg × cost
House Espresso 1kg12021.4019.802,568.001,176.00
Morning Blend 1kg9519.9019.101,890.50864.50
Brazil Cerrado 1kg8019.5018.701,560.00696.00
Colombia Huila 1kg6024.80111.201,488.00672.00
Decaf Colombia 1kg2226.20112.40576.40272.80
Ethiopia Yirgacheffe 1kg2831.50114.60882.00408.80
Kenya AA 250g4411.900.2515.80523.60173.80
Guatemala Antigua 1kg3425.60111.90870.40404.60
Sumatra Mandheling 1kg1823.70111.00426.60198.00
Cold Brew Blend 5kg1092.0058.40920.00420.00
Costa Rica Tarrazu 250g5210.800.2514.20561.60184.60
Rwanda Huye 250g2612.400.2516.10322.40104.65
Peru Organic 1kg3023.90110.80717.00324.00
Espresso Bulk 5kg1488.5058.901,239.00623.00
Honduras Marcala 1kg2422.60110.40542.40249.60
Panama Gesha 250g834.000.2542.00272.0084.00
Burundi Kayanza 250g1612.900.2516.50206.4066.00
India Monsooned 1kg1224.20111.30290.40135.60
Mexico Chiapas 1kg2022.10110.20442.00204.00
Seasonal Filter 250g3611.400.2513.90410.40125.10
Total74916,709.107,387.05

With those totals the summary block of the lab fills in like this:

CellQuestionFormulaResult
B24Order value=SUMPRODUCT(B2:B21,C2:C21)16,709.10
B25Cost of goods=SUMPRODUCT(B2:B21,D2:D21,E2:E21)7,387.05
B26Gross margin=IF(AND(B24>0,B25>0),1-B25/B24,"")55.8%
B27Average price per bag, weighted=SUMPRODUCT(B2:B21,C2:C21)/SUM(B2:B21)22.31
B28Average price per bag, simple=AVERAGE(C2:C21)27.97
B29Average score, weighted by kg=SUMPRODUCT(B2:B21,D2:D21,F2:F21)/SUMPRODUCT(B2:B21,D2:D21)83.86
B30Average score, simple=AVERAGE(F2:F21)84.95
B33Revenue forecast, 800 bags=B32*B2717,846.84

Look at the two averages for price. The simple AVERAGE says a bag sells for 27.97, the weighted average says 22.31. Why the gap? Two lines are expensive 5 kg bags (Cold Brew Blend at 92.00 and Espresso Bulk at 88.50). In a simple average each of them has the same vote as House Espresso, even though House Espresso ships 120 bags and the Cold Brew only 10. The scatter chart below makes the pattern visible: the high-volume lines on the right are all cheap, and the expensive lines sit on the far left with tiny volumes.

020406080100020406080100120Bags orderedPrice per bagsimple AVERAGE 27.97weighted by bags 22.31Cold Brew 5kgEspresso Bulk 5kgHouse Espresso
Each dot is one product line. The weighted average (blue) is pulled down by the big, cheap orders on the right; the simple average (peach) is pulled up by a few expensive low-volume lines.

The same thing happens to quality. The simple average cupping score is 84.95, but the score weighted by kilos actually shipped is only 83.86. The premium single origins with scores of 87 and more are mostly sold in 250 g bags, so they represent very little coffee. If Tidewell told cafés that its average coffee scores 85, it would be overstating what customers actually receive.

Which average belongs in the forecast?

Sales plans 800 bags next quarter in the same product mix. A forecast multiplies bags by an average price, so the choice of average decides the number. There is a simple test you can always use: apply each average to this quarter and see whether it reproduces the real total. 749 bags × the weighted average in B27 (22.3085…, displayed as 22.31) gives exactly 16,709.10, the true order value, because the weighted average was built from that very number. 749 bags × 27.97 gives 20,945.79, about 25 percent too much.

Revenue forecast for 800 bags next quarter800 × simple 27.9722,372.00800 × weighted 22.3117,846.84Q3 actual for 749 bags: 16,709.10Test on Q3: 749 × B27 = 16,709.10 (exact) · 749 × B28 = 20,945.79 (25% too high)
For the same 800 bags, the simple average forecasts 4,525.16 more revenue than the weighted average. Only the weighted average reproduces the Q3 actuals.

So the correct forecast is =B32*B27, which returns 17,846.84. The simple-average forecast of 22,372.00 would set a target the sales team could not reach without changing the product mix, and any budget built on it (staffing, green coffee purchasing, cash flow) would inherit the error. The lesson generalises: whenever a total is the goal, the average must be weighted by the thing you multiply it with.

Step by step: building the formulas in Excel

  1. Click the result cell, for example B24, and type =SUMPRODUCT(. Excel shows the argument tooltip array1, [array2], ….
  2. Select the bags range: click B2 and press Ctrl+Shift+↓ to extend the selection to B21. Type a comma.
  3. Select the price range C2:C21 the same way, close the bracket and press Enter. The cell shows 16,709.10.
  4. For the cost of goods in B25 repeat the pattern with three arrays: =SUMPRODUCT(B2:B21,D2:D21,E2:E21).
  5. For the weighted average in B27 type =SUMPRODUCT(B2:B21,C2:C21)/SUM(B2:B21), or reuse the order value with =B24/SUM(B2:B21).
  6. If you want to copy a formula to other cells later, lock the ranges with F4 (it cycles B2:B21 → $B$2:$B$21 → B$2:B$21 → $B2:$B21).
  7. To see what SUMPRODUCT does inside, go to Formulas › Formula Auditing › Evaluate Formula and click Evaluate repeatedly. You can also select part of a formula in the formula bar and press F9 to see its array of values; press Esc afterwards so you do not overwrite the formula.
  8. Prefer the menu? Formulas › Math & Trig › SUMPRODUCT opens the Function Arguments dialog with one box per array.
  9. Check your work: press Ctrl+` (grave accent) to toggle formula view and confirm every range starts in row 2 and ends in row 21.
In Microsoft 365 you can also write =SUM(B2:B21*C2:C21), because dynamic-array Excel multiplies ranges directly. In Excel 2019 and older that formula needs Ctrl+Shift+Enter. SUMPRODUCT works the same everywhere, which is why it is still the safe choice for files you share.

SUMPRODUCT and array formulas course illustration with a spreadsheet and weighted totals
SUMPRODUCT & Array Formulas: from weighted totals to multi-condition sums, counts and lookups.

Common mistakes and how to spot them

  • Ranges of different sizes. B2:B21 with C2:C20 returns #VALUE!. Spot it by clicking into the formula: Excel colours each range, and a shorter box stands out at once.
  • Multiplying the totals. =SUM(B2:B21)*SUM(C2:C21) multiplies 749 bags by the sum of all 20 prices and returns 418,915.70, about 25 times the true order value. If a result is wildly larger than any plausible total, check whether you summed before multiplying.
  • Simple average where a weighted one is needed. AVERAGE(C2:C21) treats 8 bags of Gesha like 120 bags of House Espresso. Test any average by multiplying it back by the total weight: it should reproduce the real total.
  • Wrong denominator. If the top of a weighted average uses bags × kg, the bottom must be SUMPRODUCT(bags, kg), not SUM(bags). Say the units out loud: kilo-points divided by kilos gives points.
  • Numbers stored as text. SUMPRODUCT treats text as zero, so a quantity imported as "120" with a green triangle simply disappears from the total. Use Data › Text to Columns › Finish or multiply by 1 to convert, and compare COUNT(B2:B21) with ROWS(B2:B21).
  • Whole-column references. SUMPRODUCT(B:B,C:C) works but forces Excel to multiply more than a million rows. Use exact ranges or an Excel Table such as Orders[Bags], which grows automatically.
  • Built-in “Above average” highlighting. The conditional formatting preset compares with the simple average. For weighted questions use a formula rule such as =F2>$B$29.

Quick reference

Function or shortcutWhat it doesExample from this lesson
SUMPRODUCTMultiplies arrays row by row and adds the results=SUMPRODUCT(B2:B21,C2:C21)
SUMAdds a range; the denominator of a weighted average=SUM(B2:B21)
AVERAGESimple average, every row counts once=AVERAGE(C2:C21)
IF + ANDOnly calculate when inputs exist=IF(AND(B24>0,B25>0),1-B25/B24,"")
Ctrl+Shift+↓Extend a selection to the last filled cellSelect B2:B21 in one keystroke
F4Toggle absolute and mixed references$B$2:$B$21
F9 (in formula bar)Show the value of a selected part of a formulaSee the 20 row products
Ctrl+`Show formulas instead of resultsAudit all summary cells
Evaluate FormulaStep through a calculationFormulas › Formula Auditing

Real-world uses

The pattern from this lesson, multiply row by row and add, then divide by the weights, appears everywhere numbers are attached to quantities. A few concrete examples:

  • Sales and pricing: the average selling price of a product range weighted by units sold, used for revenue forecasts and price-increase scenarios.
  • Inventory valuation: stock on hand × unit cost per SKU in one cell, and the weighted average cost of goods in a warehouse.
  • Education and HR: a grade point average where each grade is weighted by course credits, or a performance score where criteria have different weights.
  • Finance: the weighted average interest rate of a loan portfolio (balance × rate / total balance), or a portfolio return weighted by position size.
  • Procurement: a supplier scorecard where quality, price and delivery each carry a percentage weight, which is exactly lab 8 of this course.

What you will build in the rest of this course

This lesson covered plain multiplication. The real power of SUMPRODUCT appears when you add conditions, and the following 19 lessons build on the same Tidewell data step by step.

Conditions as 1s and 0s: (range="x")*1 and the Double Unary --. You learn how a comparison such as (region="North") becomes an array of TRUE and FALSE, and how multiplying by 1 or using the double minus turns it into 1s and 0s that SUMPRODUCT can add. You then count and total one region’s orders, combine two conditions, and count orders by a calculated value such as revenue per bag, something COUNTIFS simply cannot do.

AND vs OR Logic in Arrays: Multiply, Add and the SIGN Trick. Multiplying conditions means AND, adding them means OR, but adding can double count a row that meets both criteria. You meet the SIGN trick that fixes this and build a mixed (A OR B) AND C filter in one cell.

Counting with Multiple Criteria and Partial Text: ISNUMBER(SEARCH()). Product names are messy. You count lines whose name contains a word, anywhere, with ISNUMBER(SEARCH()), combine the text test with a region and an OR on two words, and work out a weighted revenue per bag for a text match.

Distinct Counts with SUMPRODUCT(1/COUNTIF). How many different customers ordered? The classic SUMPRODUCT(1/COUNTIF()) pattern answers that, and you learn how to handle blank cells, how to count distinct values within one region and how many customers came back.

Two-Way Conditional Sums: Row and Column Criteria in One Formula. When data sits in a matrix with regions down the side and months across the top, one SUMPRODUCT can test rows and columns at the same time. You fill a full region × quarter grid with a single formula you copy across and down.

Array MAX and MIN with Conditions, and MATCH(MAX(…)) Position Lookups. Find the largest batch of one origin, the lowest yield of one roasting drum without falling into the zero trap, the ID behind the maximum, and the second-largest value, all without helper columns.

Mid-Course Project: A Weighted Supplier Scorecard with a Ranked Chart. Everything comes together in a weighted scorecard for Tidewell’s eight green-coffee suppliers: weighted criteria, a ranking, the best supplier that meets a minimum quality bar, and a chart sorted largest first that you could put in front of a buyer.

Summary

SUMPRODUCT multiplies ranges row by row and adds the results, so one cell replaces a helper column and a SUM. With a third array it handles quantity × size × cost, and divided by the sum of the weights it becomes a weighted average. The weighted average is the one that reproduces real totals, which is why it, and not AVERAGE, belongs in a forecast: for Tidewell the difference is 17,846.84 versus 22,372.00 for the same 800 bags. Watch for misaligned ranges, summing before multiplying, mismatched denominators and numbers stored as text.

Now scroll up and try it yourself in the lab: fill in the order value, the cost of goods and the weighted average price, chart bags against price to see why the averages differ, and then decide which average belongs in the forecast. The Coach checks every step and explains any mistake.

Frequently asked questions

What does SUMPRODUCT do in Excel?

SUMPRODUCT multiplies two or more ranges of the same size row by row and adds all the products. =SUMPRODUCT(B2:B21,C2:C21) is the same as multiplying B2 by C2, B3 by C3 and so on, and summing the results.

How do I calculate a weighted average in Excel?

Divide SUMPRODUCT of the values and the weights by the SUM of the weights, for example =SUMPRODUCT(B2:B21,C2:C21)/SUM(B2:B21). Each value then counts in proportion to its weight.

Why does SUMPRODUCT return #VALUE!?

Usually because the arrays have different sizes, such as B2:B21 and C2:C20. Make sure every range starts and ends on the same rows. An error value inside one of the ranges also passes through to the result.

Do I need Ctrl+Shift+Enter for SUMPRODUCT?

No. SUMPRODUCT evaluates arrays natively in every Excel version, so a normal Enter is enough. That is one reason it was the standard array tool long before dynamic arrays arrived in Microsoft 365.

What is the difference between a weighted average and AVERAGE?

AVERAGE gives every row the same vote. A weighted average lets rows with more volume, credits or balance count more. If you multiply a weighted average by the total weight, you get back the real total, which a simple average generally does not.

Can SUMPRODUCT multiply more than two columns?

Yes, it accepts up to 255 arrays. =SUMPRODUCT(B2:B21,D2:D21,E2:E21) multiplies bags by kg per bag by cost per kg on each row and adds the results.

Keep going: SUMPRODUCT & Array Formulas: Multi-Condition Sums, Counts and Lookups

This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time $9.90.

  1. Conditions as 1s and 0s: (range="x")*1 and the Double Unary --
  2. AND vs OR Logic in Arrays: Multiply, Add and the SIGN Trick
  3. Counting with Multiple Criteria and Partial Text: ISNUMBER(SEARCH())
  4. Distinct Counts with SUMPRODUCT(1/COUNTIF)
  5. Two-Way Conditional Sums: Row and Column Criteria in One Formula
  6. Array MAX and MIN with Conditions, and MATCH(MAX(…)) Position Lookups
  7. Mid-Course Project: A Weighted Supplier Scorecard with a Ranked Chart
  8. Date Conditions in Arrays: Month, Weekday and Quarter Tests That SUMIFS Cannot Do
  9. Two-Key Number Lookups with SUMPRODUCT – and the Missing and Duplicate Key Traps
  10. Ranks with SUMPRODUCT: Overall, Within a Group, Unique Tie-Breaks and Top-N Totals
  11. Size Bands with SUMPRODUCT: Counts, Totals and Rates per Band, and a Histogram
  12. Row-Wise ANY and ALL Tests over a Block: Counting Products with MMULT
  13. Price vs Volume Effects: Splitting a Revenue Change with SUMPRODUCT and a Bridge Chart
  14. Arrays on Messy Data: Numbers Stored as Text, the Comma-Style Trap and a Reconciliation Check
  15. Project: A Quarterly Order-Book Dashboard Built with SUMPRODUCT
  16. Pareto Without Sorting: Cumulative Shares and ABC Classes with SUMPRODUCT (with Chart)
  17. Tiered Rebates with SUMPRODUCT: Progressive Tiers vs All-Units and the Threshold Cliff (with Chart)
  18. Blend Recipes as a Matrix: Cost per Kilo, Green Coffee Needed and Shortages with SUMPRODUCT and MMULT (with Chart)
  19. Final Project: Account Profitability Dashboard – Revenue, Cost of Goods, Rebates and Cost-to-Serve from Raw Orders (with Chart)

Buy course — $9.90 See the full course