Excel SUMIFS Function Notes
Excel SUMIFS Function Notes
The SUMIF function is used to conditionally sum values based on a single criteria. We discussed its
syntax in detail in the previous article, so let me give you just a quick summary now.
SUMIF(range, criteria, [sum_range])
range - the range of cells to be evaluated by your criteria, required.
criteria - the condition that must be met, required.
sum_range - the cells to sum if the condition is met, optional.
As you see, the syntax of the Excel SUMIF function allows for one condition only. And still, we say that
Excel SUMIF can be used to sum values with multiple criteria. How can that be? By adding the results of
several SUMIF functions and by using SUMIF formulas with array criteria, as demonstrated in the
examples that follow.
When you're learning something new, it's always a good idea to start with simple things. So, to begin
with, let's define all the arguments for our SUMIFS formula:
sum_range - C2:C9
criteria_range1 - A2:A9
criteria1 - "apples"
criteria_range2 - B2:B9
criteria2 - "Pete"
Now assemble the above parameters, and you will get the following SUMIFS formula:
=SUMIFS(C2:C9, A2:A9, "apples", B2:B9, "Pete")
To refine the formula further, you can replace the text criteria "apples" and "Pete" with cell references. In
this case, you won't have to change the formula to calculate the quantity of other fruit from a different
supplier:
=SUMIFS(C2:C9, A2:A9, F1, B2:B9, F2)
Note. Please pay attention that in Excel SUMIFS formulas, logical expressions with comparison
operators should always be enclosed in double quotes ("").
We covered all possible comparison operators in detail when discussing Excel SUMIF function, the
same operators can be used in SUMIFS criteria. For example, the following formula with return the sum
of all values in cells C2:C9 that are greater than or equal to 200 and less than or equal to 300.
=SUMIFS(C2:C9, C2:C9,">=200", C2:C9,"<=300")
Example 2. Using Excel SUMIFS with dates
In case you want to sum values with multiple criteria based on the current date, use the TODAY()
function in your SUMIFS criteria, as demonstrated below. The following formula sums values in column
D if a corresponding date in column C falls within the last 7 days, including today:
=SUMIFS(D2:D10, C2:C10,">="&TODAY()-7, C2:C10,"<="&TODAY())
Note. When you use another Excel function together with a logical operator in the criteria, you have to
use the ampersand (&) to concatenate a string, for example "<="&TODAY().
In a similar fashion, you can use the Excel SUMIF function to sum values in a given date range. For
example, the following SUMIFS formula adds the values in cells C2:C9 if a date in column B falls
between 1-Oct-2014 and 31-Oct-2014, inclusive.
=SUMIFS(C2:C9, B2:B9, ">=10/1/2014", B2:B9, "<=10/31/2014")
The same result can be achieved by calculating the difference of two SUMIF functions, as demonstrated
in this example - How to use SUMIF to sum values in a given date range. However, Excel SUMIFS is
much easier and more understandable, isn't it?
Example 3. Excel SUMIFS with blank and non-blank cells
When analyzing reports and other data, you may often need to sum values corresponding either to
empty or non-empty cells.
Criteria Description Formula Example
=SUMIFS(C2:C10, A2:A10, "=",
Sum values corresponding
B2:B10, "=")
to blank cells that contain
"=" absolutely nothing - no
Sum values in cells C2:C10 if the
formula, no zero length
corresponding cells in columns A and
string.
B are absolutely empty.
Blank
Sum values corresponding
cells =SUMIFS(C2:C10, A2:A10, "",
to "visually" blank cells
B2:B10, "")
including those that contain
"" empty strings returned by
Sum values in cells C2:C10 with the
some other Excel function
same conditions as the above formula,
(for example, cells with a
but includes empty strings.
formula like ="").
Non- Sum values corresponding =SUMIFS(C2:C10, A2:A10, "<>",
"<>"
blank to non-empty cells, B2:B10, "<>")
cells including zero length
strings. Sum values in cells C2:C10 if the
corresponding cells in columns A and
B are not empty, including cells with
empty strings.
=SUM(C2:C10) - SUMIFS(C2:C10,
A2:A10, "", B2:B10, "")
SUM-
Sum values corresponding
SUMIF =SUM((C2:C10) *
to non-empty cells, not
or (LEN(A2:A10)>0)*(LEN(B2:B10)>0))
including zero length
SUM / Sum values in cells C2:C10 if the
strings.
LEN corresponding cells in columns A and
B are not empty, cells with zero length
strings are not included.
And now, let's see how you can use a SUMIFS formula with "blank" and "non-blank" criteria on real data.
Suppose, you have an order date in column B, delivery date in column C and Qty. in column D. How do
you find the total of products that have not been delivered yet? That is, you want to know the sum of
values corresponding to non-empty cells in column B and empty cells in column C.
The solution is to use the SUMIFS formula with 2 criteria:
=SUMIFS(D2:D10, B2:B10,"<>", C2:C10,"=")
Using Excel SUMIF with multiple OR criteria
As noted in the beginning of this tutorial, the SUMIFS function is designed with AND logic. But what if
you need to sum values with multiple OR criteria, i.e. when at least one of the conditions is met?
Example 1. SUMIF + SUMIF
The simplest solution is to sum the results returned by several SUMIF functions. For example, the
following formula demonstrates how to find the total of products delivered by Mike and John:
=SUMIF(C2:C9,"Mike",D2:D9) + SUMIF(C2:C9,"John",D2:D9)
As you see, the first SUMIF function adds the quantities corresponding to "Mike", the other SUMIF
function returns the amounts relating to "John" and then you add these 2 numbers.
Example 2. SUM & SUMIF with an array argument
The above solution is very simple and may get the job done quickly when there are only a couple of
criteria. But a SUMIF + SUMIF formula may grow up enormously if you want to sum values with multiple
OR conditions. In this case, a better approach is using an array criteria argument in the SUMIF
function. Let's examine this approach now.
You can start by listing all of your conditions separated by commas and then enclose the resulting
comma-separated list in {curly brackets}, which is technically called an array.
In the previous example, if you want to sum the products delivered by John, Mike and Pete, your array
criteria will look like {"John","Mike","Pete"}. And the complete SUMIF function is SUMIF(C2:C9,
{"John","Mike","Pete"} ,D2:D9).
The array argument consisting of 3 values forces your SUMIF formula to return three separate results,
but since we write the formula in a single cell, it would return the first result only - i.e. the total of
products delivered by John. To get this array-criteria approach to work, you have to use one more little
trick - enclose your SUMIF formula in a SUM function, like this:
=SUM(SUMIF(C2:C9, {"John","Mike","Pete"} , D2:D9))
As you see, an array criteria makes the formula much more compact compared to SUMIF + SUMIF, and
lets you add as many values as you like in the array.
This approach works with numbers as well as with text values. For instance, if instead of the suppliers'
names in column C, you had supplier IDs like 1, 2, 3 etc., then your SUMIF formula would look similar to
this:
=SUM(SUMIF(C2:C9, {1,2,3} , D2:D9))
Unlike text values, numbers needn't be enclosed in double quotes in array arguments.
Example 3. SUMPRODUCT & SUMIF
In case, your preferred way is to list the criteria in some cells rather that specify them directly in the
formula, you can use SUMIF in conjunction with the SUMPRODUCT function that multiplies components
in the given arrays, and returns the sum of those products.
=SUMPRODUCT(SUMIF(C2:C9, G2:G4, D2:D9))
Where G2:G4 are the cells containing your criteria, the suppliers' names in our case, as illustrated in the
screenshot below.
But of course, nothing prevents you from listing the values in an array criteria of your SUMIF function if
you want to:
=SUMPRODUCT(SUMIF(C2:C9, {"Mike","John","Pete"}, D2:D9))
The result returned by both formulas will be identical to what you see in the screenshot:
Many people wonder why use double dash (--) in SUMPRODUCT formulas. The point is that Excel
SUMPRODUCT ignores all but numeric values, while the comparison operators in our formula return
Boolean values (TRUE / FALSE), which are non-numeric. To convert these Boolean values to 1's and
0's, you use the double minus sign, which is technically called the double unary operator. The first unary
coerces TRUE/FALSE to -1/0, respectively. The second unary negates the values, i.e. reverses the sign,
turning them into +1 and 0, which the SUMPRODUCT function can understand.
I hope the above explanation makes sense. And even if it doesn't, just remember this rule of thumb - use
the double unary operator (--) when you are using comparison operators in your SUMPRODUCT
formulas.
Note. When entering any array formula, you must press Ctrl + Shift + Enter. Once you do this, your
formula gets enclosed in {curly braces}, which is a visual indication that an array formula is entered
correctly. If you try typing the braces manually, your formula will be converted to a text string, and it
won't work.
Example 2. SUM array formulas in modern Excel versions
Even in modern versions of Excel 2016, 2013, 2010 or 2007, the power of the SUM function should not
be underestimated. The SUM array formula is not simply gymnastics of the mind, but has a practical
value, as demonstrated in the following example.
Suppose, you have two columns, B and C, and you need to count how many times column C is greater
than column B, when a value in column C is greater or equal to 10. An immediate solution that comes to
mind is using the SUM array formula:
=SUM((C1:C10>=10) * (C1:C10>B1:B10))
Don't see any practical application to the above formula? Think about it in another way : )
Suppose, you have the orders list like shown in the screenshot below and you want to know how many
products have not been delivered in full by a given date. Translated into Excel's language, we have the
following conditions:
Condition 1: A value in column B (Ordered items) is greater than 0
Condition 2: A value in column C (Delivered) in less than in column B
Condition 3: A date in column D (Due date) is less than 11/1/2014.
Putting the three range/condition pairs together, you get the following formula:
=SUM((B2:B10>=0)*(B2:B10>C2:C10)*(D2:D10<G2))