You are on page 1of 7

Math and Statistical Functions

Do not let the term statistics scare you. Every day, you rely on statistics to make routine
decisions. When you purchase a car, you compare the average miles per gallon (MPG)
among several vehicles. The automobile manufacturer conducted multiple test drives,
recorded the MPG under various driving conditions, and then calculated the MPG sta-
tistic based on average performance. Statistics involve analyzing a collection of data and
making inferences to draw conclusions about a dataset.
You have already learned to use the SUM, AVERAGE, MIN, MAX, MEDIAN, and
COUNT statistical functions. However, sometimes you might want to calculate a statistic
based on a particular condition. Excel’s math and statistical function categories contain
functions that enable you to perform conditional calculations, such as calculating a total
only when a particular circumstance or set of circumstances exists.
In this section, you will use math and statistical functions—SUMIF, AVERAGEIF,
COUNTIF, SUMIFS, AVERAGEIFS, and COUNTIFS—to perform conditional statisti-
cal calculations. In addition, you will use relative-standing functions, such as RANK,
PERCENTRANK, PERCENTILE, and QUARTILE.

Using Conditional Math and Statistical


Functions
When you use SUM, AVERAGE, and COUNT functions, Excel calculates the respective
total, the mathematical average, and the number of values for all values in the range
specified in the function’s arguments. The math and statistical function categories con-
tain related functions—SUMIF, AVERAGEIF, COUNTIF, SUMIFS, AVERAGEIFS, and
COUNTIFS—that perform similar calculations but based on a condition. These functions
are similar to the logical function IF. As you recall, the IF function evaluates a logical test
to determine if it is true or false. If the logical test is true, Excel returns one result; if the
logical test is false, it returns a different result. These conditional math and statistical
functions are a hybrid of math/statistical and logical functionality. Basically, instead of
delivering a value of true or false, these functions perform a specific calculation when
specified conditions are met. Figure 8.2 shows a salary table for educators in the district
and the results of these math and statistical functions.

512 Chapter 8 • Statistical Functions

M09_GRAU9446_01_SE_E08.indd 512 2/2/16 11:23 PM


Function in cell D15

Functions with one condition

Excel 2016, Windows 10, Microsoft Corporation


Functions with two conditions

FIGURE 8.2 Math and Statistical Functions

Use the SUMIF, AVERAGEIF, and COUNTIF Functions


STEP 1 The SUMIF function is a statistical function similar to the SUM function except that it
calculates the total of a range of values when a specified condition is met. For example,
in Figure 8.2, if you want to calculate the total salaries for all high school teachers in
the district, you cannot use the SUM function because it would calculate the total sala-
ries for teachers in the district’s elementary and intermediate schools as well. However,
you can complete the task using the SUMIF function. In Figure 8.2, cell D15 contains
the results of the function =SUMIF(C2:C13,"high school",D2:D13) to sum the Salary
column (D2:D13) if the Teaching Assignment column (C2:C13) contains the text high
school. The total value of salaries for high school teachers is $247,447.00. The SUMIF
function contains three required arguments:
=SUMIF(range,criteria,sum_range)

• Range. The range argument specifies the range of cells you want to evaluate to
determine if the values meet a particular condition. In Figure 8.2, the SUMIF
function’s range is C2:C13, the range containing the teaching assignments.
• Criteria. The criteria argument specifies the condition that imposes limitations
on what values Excel sums. The criteria can be a value, date, text, or another
cell containing a value, date, or text. In Figure 8.2, the SUMIF function criterion
is the text high school. Excel restricts the totaling to rows in which the range
contains only high school. When you use text as a criterion, you must enclose it

Math and Statistical Functions • Excel 2016 513

M09_GRAU9446_01_SE_E08.indd 513 2/2/16 11:23 PM


within quotation marks. When you use values as criteria, do not use quotation
marks. You can also create an input range to specify the condition and then
simply use a cell reference as the criteria argument in the SUMIF function.
• Sum_range. The sum_range argument designates the cells containing values
to add if the condition is met. In Figure 8.2, the SUMIF function’s sum_range is
D2:D13, the range containing the salaries.

TIP: Quotation Marks


When entering criteria that contain text, a date, or an operator such as <, you must surround the
criteria with quotation marks. If you enter the criteria using the Function Argument box, Excel will
automatically add quotation marks. If you type the function from scratch instead of using the insert
function button, you must type the quotation marks manually.

The AVERAGEIF function calculates the average, or arithmetic mean, of all


cells in a range that meet a specific condition. In Figure  8.2, cell D16 contains
=AVERAGEIF(C2:C13,"high school",D2:D13) to calculate the average value in the
Salary column (D2:D13) when the Teaching Assignment column (C2:C13) contains the
text high school. The average high school teacher’s salary is $49,489.40.
=AVERAGEIF(range,criteria,average_range)
The AVERAGEIF function contains three required arguments: range, criteria, and
average_range. The range and criteria arguments have the same meanings as the same
arguments in the SUMIF function. The average_range argument specifies the range con-
taining values that you want to average if the condition is met. In the AVERAGEIF func-
tion, the average_range is D2:D13.

TIP: Referencing the Input Range


When using the SUMIF, AVERAGEIF, and COUNTIF functions, you can create an input range to specify
the condition and then simply use a cell reference as the criteria argument in the function. This allows
the user the flexibility to change the criteria and receive instant calculation updates.

The COUNTIF function is a statistical function, similar to the COUNT function


except that it counts the number of cells in a range when a specified condition is met. In
Figure 8.2, cell D17 contains =COUNTIF(C2:C13,"high school") to count the number of
high school teachers, which is five.
=COUNTIF(range,criteria)
The COUNTIF function contains only two arguments: range and criteria. Similar to
the SUMIF and AVERAGEIF functions, the range argument for the COUNTIF function
specifies the range of cells you want to evaluate to see if the values meet a particular
condition. The criteria argument specifies the condition to be met in order to count cells
in the designated range.

Use the SUMIFS, AVERAGEIFS, and COUNTIFS Functions


Step 2 Whereas the previously described functions enable you to perform conditional calcula-
tions, they can address only a single condition. Similar math and statistical functions
enable you to specify more than one condition: SUMIFS, AVERAGEIFS, and COUNTIFS.
The SUMIFS function calculates the total value of cells in a range that meet
multiple criteria. In Figure 8.2, cell D19 contains =SUMIFS(D2:D13,C2:C13,"high
school",B2:B13,"Jackson"). This function sums the Salary range if the teaching assign-
ment range contains high school and if the township range contains Jackson. The total

514 Chapter 8 • Statistical Functions

M09_GRAU9446_01_SE_E08.indd 514 07/04/16 3:33 PM


salary of high school teachers in Jackson Township is $89,046.00. The SUMIFS function
contains at least five arguments: sum_range, criteria_range1, criteria1, criteria_range2,
and criteria2. Additional ranges and their criteria may be included. All conditions must
be met in order to include values in the sum_range in the total.
=SUMIFS(sum_range,criteria_range1,criteria1,criteria_range2,criteria2…)

• Sum_range. The sum_range argument designates the cells containing values


to add if the condition is met. In the SUMIFS function, the sum_range argument
is the first argument instead of the last argument as in the SUMIF function. In
Figure 8.2, the SUMIFS function’s sum_range is D2:D13, the range containing
the salaries.
• Criteria_range1. The range argument specifies the first range of cells you
want to evaluate to see if the values meet a particular condition. The range must
contain values, range names, arrays, or references that contain numbers, dates,
or text. In Figure 8.2, the criteria_range1 is C2:C13, the range containing the
teaching assignments.
• Criteria1. The criteria1 argument specifies the condition for the criteria_range1
argument that imposes limitations on what values are summed. In Figure 8.2,
the SUMIFS function’s criteria1 argument is high school.
• Criteria_range2. The range argument specifies the second range of cells you
want to evaluate to see if the values meet a particular condition. The range must
contain values, range names, arrays, or references that contain numbers, dates,
or text. In Figure 8.2, the SUMIFS function’s criteria_range2 is B2:B13, the
range containing the township.
• Criteria2. The criteria2 argument specifies the condition that imposes
limitations on what values are summed. In Figure 8.2, the SUMIFS function’s
criteria2 is Jackson.
The AVERAGEIFS function calculates the average value of cells in a range that meet
multiple criteria. In Figure 8.2, cell D20 contains =AVERAGEIFS(D2:D13,C2:C13,"high
school",B2:B13,"Jackson"). This function calculates the average value in the Salary
range if the teaching assignment is high school and if the township is Jackson. The average
salary of high school teachers in Jackson Township is $44,523. The AVERAGEIFS func-
tion contains at least five arguments. The average_range argument specifies the range
of cells containing values that will be averaged when multiple conditions specified by the
criteria ranges and criteria are met.
=AVERAGEIFS(average_range,criteria_range1,criteria1,criteria_range2,criteria2…)
The COUNTIFS function counts the number of cells in a range that meet
multiple criteria. In Figure  8.2, cell D21 contains =COUNTIFS(C2:C13,"high
school",B2:B13,"Jackson"). This function counts the number of high school teachers
in Jackson Township, which is two. The COUNTIFS function contains at least four argu-
ments: two ranges and their respective criteria.
=COUNTIFS(criteria_range1,criteria1,criteria_range2,criteria2…)

TIP: ADDITIONAL CRITERIA


Whereas the syntax shows only two criteria for SUMIFS, AVERAGEIFS, and COUNTIFS, you can
continue adding criteria ranges and criteria. If you type the function in a cell, separate criteria ranges
and criteria with commas. If you use the Function Arguments dialog box, it expands to display another
Criteria box as you enter data in existing boxes, or you can press Tab within the dialog box to see
additional criteria ranges and criteria boxes.

Math and Statistical Functions • Excel 2016 515

M09_GRAU9446_01_SE_E08.indd 515 2/2/16 11:23 PM


Hands-On Exercises Watch the Video
for this Hands On
Exercise!
HOE1 Training

Skills covered: Use the


SUMIF, AVERAGEIF, and COUNTIF 1 Math and Statistical Functions
Functions • Use the SUMIFS,
AVERAGEIFS, and COUNTIFS For the first step of your assessment, you calculate summary statistics of the teachers’ salaries. First,
Functions • Enter Math and Statistical you want to calculate statistics, such as average salary for teachers hired before 2005. You then will turn
Functions • Use the Rank and your attention to the Acorn Township, the township with the fewest teachers, as you perform statistical
PERCENTRANK Functions • Use calculations. Finally, you want to rank each person’s salary compared to the other salaries and identify the
the QUARTILE and PERCENTILE salary ranges for each quartile.
Functions

Step 1 USE SUMIF, AVERAGEIF, AND COUNTIF FUNCTIONS


You want to calculate the number of high school teachers that were hired before 1/1/2005. You also want to calculate the average
salary and total payroll for all high school teachers hired before 1/1/2005. You will use SUMIF, COUNTIF, and AVERAGEIF to
complete the calculations. Refer to Figures 8.5 and 8.6 as you complete Step 1.

Step b: Click to select math function

Steps b-d: COUNTIF function


in the Formula Bar

Steps d: Quotes entered


automatically around text

Excel 2016, Windows 10, Microsoft Corporation

FIGURE 8.5 COUNTIF Function

520 Chapter 8 • Hands-On Exercise 1

M09_GRAU9446_01_SE_E08.indd 520 2/2/16 11:23 PM


Steps e–f: SUMIF
Steps g–h: AVERAGEIF
function results
function in cell H5

Steps g–h: AVERAGEIF


function results

Excel 2016, Windows 10, Microsoft Corporation


FIGURE 8.6 SUMIF and AVERAGEIF Functions

a. Open e08h1Assessment and save it as e08h1Assessment_LastFirst. Ensure the


Educator Assessment worksheet tab is displayed.

TROUBLESHOOTING:  If you make any major mistakes in this exercise, you can close the file,
open e08h1Assessment again, and then start this exercise over.

b. Click cell H3, click the Formulas tab, click More Functions in the Function Library
group, point to Statistical, scroll through the list, and then select COUNTIF.
Cell H3 is the cell in which you want to calculate the total number of high school
teachers hired before 1/1/2005. The Function Arguments dialog box opens so that you
can enter the range and criteria arguments.
c. Select the range B3:B52 to enter it in the Range box.
The range B3:B52 contains the data array that contains the values to be counted.
d. Click in the Criteria box, type <1/1/2005, and then click OK.
The newly created function indicates there are 16 teachers that meet the criteria
requirements.
e. Click cell H4, click Math & Trig in the Function Library group, and then select SUMIF.
The Function Arguments dialog box displays so that you can enter the range, criteria,
and sum_range arguments.
f. Type B3:B52 in the Range box, type <1/1/2005 in the Criteria box, and then type
C3:C52 in the Sum_range box: Click OK to exit the Function Arguments box.
The total salaries paid to high school teachers hired before 1/1/2005 is $790,922.00.
g. Ensure cell H5 is selected. Click More Functions in the Function Library group, point
to Statistical, and then select AVERAGEIF.
h. Type B3:B52 in the Range box, type <1/1/2005 in the Criteria box, and then type
C3:C52 in the Average_range box. Click OK to exit the Function Arguments box.
The average salary for high school teachers hired before 1/1/2005 is $49,432.63.

Hands-On Exercise 1 521

M09_GRAU9446_01_SE_E08.indd 521 2/2/16 11:23 PM


Step 2 ENTER SUMIFS, AVERAGEIFS, AND COUNTIFS FUNCTIONS
Now you want to focus on the summarizing data for high school teachers hired before 1/1/2005 in Acorn Township. Specifically,
you want to calculate the total number of educators, total salary payroll, and average salary. Because each of these calculations
requires two criteria, you will use the SUMIFS, AVERAGEIFS, and COUNTIFS functions. Refer to Figure 8.7 as you complete Step 2.

Steps a-c: COUNTIFS


function in cell H8

Excel 2016, Windows 10, Microsoft Corporation


Step e: SUMIFS
function results

Step f: AVERAGEIFS
function results

FIGURE 8.7 SUMIFS, AVERAGEIFS, and COUNTIFS Functions

a. Click cell H8, click More Functions and point to Statistical in the Function Library
group, scroll through the list, and then select COUNTIFS.
b. Type B3:B52 in the Criteria_range1 box, click in the Criteria1 box, and then type
<1/1/2005.
Similar to the COUNTIF function, COUNTIFS has the ability to count data points in a
range that match specified criteria. In this step the first criterion is <1/1/2005.
c. Click in the Criteria_range2 box and type D3:D52. Type Acorn in the Criteria 2 box and
click OK.
The function returns 6, the total number of high school teachers in Acorn Township
hired before 1/1/2005, by using the criteria <1/1/2005 and Acorn to filter the data
ranges B3:B52 and D3:D52.
d. Click cell H9, click Math & Trig in the Function Library group, and then select SUMIFS.
e. Type C3:C52 in the Sum_range box, type B3:B52 in the Criteria_range1 box, type
<1/1/2005 in the Criteria1 box, type D3:D52 in the Criteria_range2 box, type Acorn
in the Criteria2 box, and then click OK.
The total payroll for high school teachers in Acorn Township hired before 1/1/2005 is
$289,587.00.

TROUBLESHOOTING:  If you misspell criterion text, such as the township name, the results will
display 0. Always check the criterion text to make sure it matches text in the respective column.

f. Click cell H10,type =AVERAGEIFS(C3:C52,B3:B52,"<1/1/2005",D3:D52,


"Acorn"), and press Ctrl+Enter manually.
The average salary of high school teachers in Acorn Township hired before 1/1/2005 is
$48,264.50.
g. Save the workbook.

522 Chapter 8 • Hands-On Exercise 1

M09_GRAU9446_01_SE_E08.indd 522 2/2/16 11:23 PM

You might also like