You are on page 1of 11

How to use the COUNTIF and SUMIF functions in Excel — a quick introductory tutorial

I wanted to continue building on my popular series on how to use IF statements and nested IF statements with “and, or, not” in Excel by discussing two additional and very useful functions called countif and sumif. Surprisingly, they’re not as widely used as you’d expect, and sometimes knowing which to use is a bit confusing. Countif is a function that will count (as in 1, 2, 3…) the number of entries within a range if certain criteria are met, and the data within each entry can be text or numbers. Sumif, on the other hand, is a function that will add the total number of numerical entries within a range if certain criteria are met. This means that sumif only works with numbers when adding up figures, so if your range includes any text, those will be ignored. Let’s walk through a simple example. Suppose you have the following simple table of sales by type and # for each year from 2003-2009:

And what you’d like to know is how many sales of each type (in your store vs. by phone vs. online) were done in total. Countif will help you figure that out quickly. First, let’s enter the type of sale we’re interested in in a column to the right:


the range you’re interested in and the criteria that need to be met: In our case. so we input that into the first part of the countif function: 2 .Next. countif takes two inputs. we’ll type in the “countif” function. the data (store type) is in column B. As you can see.

or what we’ve typed into cell E2: 3 . we want each entry to be counted only if the type of sale was “store”.Next.

we immediately get the result. remember to always put quotation marks (“”) around the criteria when working with text! Either way. we could type it directly into the function like this: =countif(B2:B20. “store”) By the way.Note that if we hadn’t typed in “store” in E2. Repeating the same thing for “telephone”: 4 . There were 7 sales from 2003-2009 that took place at the store (one for each year). once we close the parenthesis and hit.

We find the same result — 7 sales. Now let’s check “online”: Turns out we had less online sales (maybe because we didn’t launch a website that accepted sales until 2005): 5 .

That’s fine and dandy. For “store” sales. sumif takes in slightly different inputs than countif. but not particularly useful info. we’d want to use the sumif function. we’d enter in sumif and the appropriate inputs as follows. How about if we wanted to know the total number of sales by type for the entire period ? In that case. very similar to countif: 6 . The first input is the range that you’re interested in. First.

which is in column C: 7 . In this case. which in this case is also identical to what we put in for countif above: But sumif also takes one additional argument: the range to be summed. we want to know the total number of sales.The second input is the criteria.

we find that we had 211 total sales in the store from 20032009: Again. let’s repeat the same thing to find the total number of telephone sales: 8 .Closing out the parenthesis.

…and online sales: See the difference between what countif gives and what sumif gives? Note that sumif can also take in different criteria. Let’s suppose we wanted to know the total number of sales that have taken place starting in 2008. To do this. we could make our range the year. found in column A: 9 . regardless of type.

and then add in the criteria of “>= 2008″: Finally. we again want to sum up the total number of sales. which is in column C: Closing out our final parenthesis. we get that we have had a total of 141 sales from 2008-2009: 10 .

A quick intro tutorial to using countif and sumif. these can get as complicated as you’d like (at the expense of readability). That’s it for now. so always try to keep it as simple as possible. 11 .Finally. just a quick example here will show what happens if you put in non-numerical data to sum using the sumif function. Let’s change the number of store sales in 2008 from “37″ to “nonsense” and see what happens: Notice how the calculations automatically ignore that entry. and the total number of store sales and the total number of sales since 2008 both drop by 37. Like most other Excel functions.