As the formula is copied across and down, it returns a sum of values associated with "A" and "B" in the table to the left.
In this example, the goal is to sum the values in columns C, E, G, and I conditionally using the text values in columns B, D, F, and H for criteria. This problem can be solved with the SUMPRODUCT function, which is designed to multiply ranges or arrays together and return the sum of products. The formula in K5 is:
Working from the inside out, SUMPRODUCT is configured with two arguments, array1 and array2. The first array, array1, is set up to act as a "filter" to allow only values that meet criteria:
Note: both references above are mixed references. $B5:$H5 has the columns locked, so that the formula can be copied across. K$4 has the row locked so that the formula can be copied down.
All values in the range B5:H5 are compared to the value in K4. The result is an array of TRUE and FALSE values like this:
In this array, each TRUE value corresponds to the value "A" in B5:H5, and FALSE values correspond to other values. The double negative (--) is used to convert the TRUE and FALSE values to 1s and 0s and the result looks like this:
Next, SUMPRODUCT multiplies the two arrays together. Only the values in the second array that correspond to 1s in the first array survive this operation. Since SUMPRODUCT is programmed to ignore the errors that result from multiplying text values, the final array looks like this:
SUMPRODUCT then sums the array and returns a final result of 4.
In this example, the goal is to sum every nth value by column in a range of data, as seen in the worksheet above. For example, if n =2, we want to sum every second value by column, if n =3, we want to sum every third value by column, and so on. All...
The Excel SUMPRODUCT function multiplies ranges or arrays together and returns the sum of products. This sounds boring, but SUMPRODUCT is an incredibly versatile function that can be...
Excel Formula Training
Formulas are the key to getting things done in Excel. In this accelerated training, you'll learn how to use formulas to manipulate text, work with dates and times, lookup values with VLOOKUP and INDEX & MATCH, count and sum with criteria, dynamically rank values, and create dynamic ranges. You'll also learn how to troubleshoot, trace errors, and fix problems. Instant access. See details here.