Using The COUNTIF Function in Microsoft Excel 2007

By Andrew Whiteman

The COUNTIF function enables us to count the number of cells in a given range which satisfy a condition. COUNTIFS does exactly the same. However, with COUNTIFS, we can specify multiple criteria. For instance, let's say we have a worksheet containing four columns: the date, the number of phone calls received, the number of complaints and the percentage of calls which were actually complaints.

We would now like to create a summary worksheet to calculate the number of days where the percentage of calls that were complaints is, firstly, under 5%; secondly, between five and 10% and, thirdly, over 10%.

To find those days where there were fewer than 5% or more than 10%, we can use COUNTIF function because we are dealing with a simple condition: less than 5% or greater than 10%. However, to find those days where there were between 5% and 10%, we will need to use multiple criteria; firstly, greater than or equal to five and, secondly, less than or equal to 10. For this reason, we will need the COUNTIFS function.

When creating formulas, it is always useful to give names to the ranges of cells are you are referencing. To allow Excel create the names for you automatically, select all of your data, including the column headings then, in the Formulas Tab of the Excel Ribbon, click on Create from Selection. Switch on the option "Create names from values in the Top Row" and click OK. Let's assume that the heading at the top of the fourth column (the one containing the percentage of calls which were actually complaints) is "Percentage", this would be the name that we would use in our COUNTIF formulas.

Having created our named ranges, we can switch to the report worksheet and click in the cell where we want to calculate the total number of days where less than 5% of our calls were complaints. Here we would enter our formula: =COUNTIF(Percentage,"<5"). Notice how, when using COUNTIF and COUNTIFS, the criteria are always surrounded by quotation marks.

In exactly the same way, to calculate the total number of days where more than 10% of our calls were complaints, we would use the formula =COUNTIF(Percentage,">10").

Finally, to calculate the total number of days where between 5 and 10% of our calls were complaints, we would use the formula =COUNTIFS(Percentage,">=5",Percentage,"<=10"). The COUNTIFS function allows you to repeat the two arguments used with the COUNTIF function (criteria range and criteria) up to 127 times. Thus, in our example, criteria range 1 is Percentage; criteria 1 is ">=5"; criteria range 2 is also Percentage; and criteria 2 is "<=10". - 20765

About the Author:

0 comments: