Where “data” in an Excel Table in the range B5:D15. The result is the quantity associated with “Red” (5), excluding “RED”. Note that if there is more than one match (i.e. exact match duplicate colors), SUMPRODUCT will sum matching results. Note: while this is an array formula, it does not need to be entered with Control + Shift + Enter, since SUMPRODUCT handles arrays natively. The SUMPRODUCT function multiplies arrays together and returns the sum of products. If only one array is supplied, SUMPRODUCT will simply sum the items in the array. For example, if we give SUMPRODUCT one array in the form of the data[Qty] column: SUMPRODUCT returns 54, the total of all numbers in the Qty column, like this: What we need now is a way to “filter” these values to include only the value associated with “Red”, respecting case. In other words, we need to test the values in the Color column and only allow those associated with “Red” to make it through. We can do this with the EXACT function, which is designed to perform a case-sensitive comparison of text strings. We use EXACT like this: Because we are comparing the in value in F5 (“Red”) with the eleven values in the Color column, the EXACT function returns 11 results in an array like this: Next, we use a double negative (–) in front of EXACT to convert the TRUE and FALSE values to 1s and 0s. The resulting array looks like this: Notice the 1 in the 5th position corresponds to the “Red” in row 5. Every other value is now a zero. This will work perfectly as a filter. Turning back to the formula in G5, we can see how this works. The formula is evaluated like this: Each array is evaluated, the two arrays are multiplied together, and SUMPRODUCT returns the sum of the products. The FALSE values created with the EXACT function become zeros, and the zeros effectively cancel out the other values when the two arrays are multiplied together. The only values that survive are those associated with TRUE, and the final result is 5. Remember, this formula only works for numeric values, because SUMPRODUCT doesn’t handle text.

### Case-sensitive sum

Note that because we are using SUMPRODUCT, this formula comes with a unique twist: if there are multiple matches, SUMPRODUCT will return the sum of those matches. For example, the value in cell F6 is “RED”, which appears twice in the Color column. The formula in G6 returns 9 like this: The value “RED” appears in row 3 and row 8 of the table, and the final sum is 9.

### Compact syntax

In more advanced SUMPRODUCT formulas, you will often see an abbreviated syntax like this: Notice we are now providing just one array to SUMPRODUCT, which is a result of multiplying the two arrays together directly. The advantage to this approach is that we no longer need to use the double negative. The math operation of multiplying the arrays together automatically coerces the TRUE and FALSE values in the first array into 1s and 0s.

### Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.