Home > Articles

Cluster Analysis in Excel

Learn how to calculate the mean, median, and mode of your data in Excel 2016.

Save 35% off the list price* of the related book or multi-format eBook (EPUB + MOBI + PDF) with discount code ARTICLE.
* See informit.com/terms

This chapter is from the book

In This Chapter

  • Calculating the Mean
  • Calculating the Median
  • Calculating the Mode
  • From Central Tendency to Variability

When you think about a group that’s measured on some numeric variable, you often start thinking about the group’s average value. On a scale of 1 to 10, how well do registered Independents think the president is doing? What is the average market value of a house in Minneapolis? What’s the most popular first name for boys born last year?

The answer to each of those questions, and questions like them, is usually expressed as an average, although the word average in everyday usage isn’t well defined, and you would go about figuring each average differently. For example, to investigate presidential approval, you might go to 100 Independent voters, ask them each for a rating from 1 to 10, add up all the ratings, and divide by 100. That’s one kind of average, and it’s more precisely termed the mean.

If you’re after the average cost of a house in Minneapolis, you probably ask some group such as a board of realtors. They’ll likely tell you what the median price is. The reason you’re less likely to get the mean price is that in real estate sales, there are always a few houses that sell for really outrageous amounts of money. Those few houses pull the mean up so far that it isn’t really representative of the price of a typical house in the region you’re interested in.

The median, on the other hand, is right on the 50th percentile for house prices; half the houses sold for less than the median price and half sold for more. (It’s a little more complicated than this, and I’ll cover the complexities shortly.) It isn’t affected by how far some home prices are from an average, just by how many are above an average. In that sort of situation, where the distribution of values isn’t symmetric, the median often gives you a much better sense of the average, typical value than does the mean.

And if you’re thinking of average as a measure of what’s most popular, you’re usually thinking in terms of a mode—the most frequently occurring value. For example, in 2015, Noah was the modal boy’s name among newborns.

Each of these measures—the mean, the median, and the mode—is legitimately if imprecisely thought of as an average. More precisely, each of them is a measure of central tendency: that is, how a group of people or things tend to cluster in some way around a central value.

Calculating the Mean

When you’re reading, talking, or thinking about statistics and the word mean comes up, it refers to the total divided by the count. The total of the heights of everyone in your family divided by the number of people in your family. The total of the price per gallon of gasoline at all the gas stations in your city divided by the number of gas stations. The total number of a baseball player’s hits divided by the number of at bats.

In the context of statistics, it’s very convenient, and more precise, to use the word mean this way. It avoids the vagueness of the word average, which—as just discussed—can refer to the mean, to the median, or to the mode.

So it’s sort of a shame that Excel uses the function name AVERAGE() instead of MEAN(). Nevertheless, Figure 2.1 gives an example of how you get a mean using Excel.

Figure 2.1

The AVERAGE() function calculates the mean of its arguments.

Figure 2.1

Understanding the elements that Excel’s worksheet functions have in common with one another is important to using them properly, and of course, you can’t do good statistical analysis in Excel without using the statistical functions properly. There are more statistical worksheet functions in Excel, over 100, than any other function category. So I propose to spend some ink here on the elements of worksheet functions in general and statistical functions in particular. A good place to start is with the calculation of the mean, shown in Figure 2.1.

Understanding Functions, Arguments, and Results

The function that’s depicted in Figure 2.1, AVERAGE(), is a typical example of statistical worksheet functions.

Defining a Worksheet Function

An Excel worksheet function—more briefly, a function—is just a formula that someone at Microsoft wrote to save you time, effort, and mistakes.

Suppose that Excel had no AVERAGE() function. In that case, to get the result shown in cell B13 of Figure 2.1, you would have to enter something like this in B13:

=(B2+B3+B4+B5+B6+B7+B8+B9+B10+B11) / 10

Or, if Excel had a SUM() and a COUNT() function but no AVERAGE(), you could use this:


But you don’t need to bother with those because Excel has an AVERAGE() function, and in this case you use it as follows:


So—at least in the cases of Excel’s statistical, mathematical, and financial functions—all the term worksheet function means is a prewritten formula. The function results in a summary value that’s usually based on other, individual values.

Defining Arguments

More terminology: Those “other, individual values” are called arguments. That’s a highfalutin’ name for the values that you hand off to the function—or, put another way, that you plug into the prewritten formula. In the instance of the function


the range of cells represented by B2:B11 is the function’s argument. The arguments always appear in parentheses following the function.

A single range of cells is regarded as one argument, even though the single range B2:B11 contains 10 values. AVERAGE(B2:B11,C2:C11) contains two arguments: one range of 10 values in column B and one range of 10 values in column C. (Excel has a few functions, such as PI(), that take no arguments, but you have to supply the parentheses anyway.)

Many statistical and mathematical functions in Excel take the contents of worksheet cells as their arguments—for example, SUM(A2:A10). Some functions have additional arguments that you use to fine-tune the analysis. You’ll see much more about these functions in later chapters, but a straightforward example involves the FREQUENCY() function, which was introduced in Chapter 1:


In this example, suppose that you wanted to categorize the price per gallon data in Figure 2.2 into five groups: less than $1, between $1 and $2, between $2 and $3, and so on. You could define the limits of those groups by entering the value at the upper limit of the range—that is, $1, $2, $3, $4, and so on—in cells E2:E6. The FREQUENCY() function expects that you will use its first argument to tell it where the individual observations are (here, they’re in B2:B11, called the data array by Excel) and that you’ll use its second argument to tell it where to find the boundaries of the groups (here, E2:E6, called the bins array).

So in the case of the FREQUENCY() function, the arguments have different purposes: The data array argument contains the range address of the values that you want to group, and the bins array argument contains the range address of the boundaries you want to use for the bins. The arguments behave differently according to their position in the argument list.

Contrast that with something such as =SUM(A1,A2,A3), where the SUM() function expects each of its arguments to act in the same fashion: to contribute to the total.

To use worksheet functions properly, you must be aware of the purpose of each one of a function’s arguments. Excel gives you an assist with that. When you start to enter a function into a cell in an Excel worksheet, a small pop-up window appears with the fx symbol at the left of the names (and descriptions) of functions that match what you’ve typed so far. If you double-click the fx symbol, the pop-up window is replaced by one that displays the function name and its arguments. See Figure 2.2, where the user has just begun entering the FREQUENCY() function.

Figure 2.2

The individual observations are found in the data_array, and the bin boundaries are found in the bins_array.

Figure 2.2

Excel is often finicky about the order in which you supply the arguments. In the prior example, for instance, you get a very different (and very wrong) result if you incorrectly give the bins array address first:


The order matters if the arguments serve different purposes, as they do in the FREQUENCY() function. If they all serve the same purpose, the order doesn’t matter. For example, =SUM(A2:A10,B2:B10) is equivalent to =SUM(B2:B10,A2:A10) because the only arguments to the SUM() function are its addends.

Defining Return

One final bit of terminology used in functions: When a function calculates its result using the arguments you have supplied, it displays the result in the cell where you entered the function. This process is termed returning the result. For example, the AVERAGE() function returns the mean of the values you supply.

Understanding Formulas, Results, and Formats

It’s important to be able to distinguish between a formula, the formula’s results, and what the results look like in your worksheet. A friend of mine didn’t bother to understand the distinctions, and as a consequence he failed a very elementary computer literacy course.

My friend knew that among other learning objectives he was supposed to show how to use a formula to add together the numbers in two worksheet cells and show the result of the addition in a third cell. The numbers 11 and 14 were in A1 and A2, respectively. Because he didn’t understand the difference between a formula and the result of a formula, he entered the actual sum, 25, in A3, instead of the formula =A1+A2. When he learned that he’d failed the test, he was surprised to find out that “There’s some way they can tell that you didn’t enter the formula.”

What could I say? He was pre-law.

Earlier, this chapter discussed the following example of the use of a simple statistical function:


In fact, that’s a formula. An Excel formula begins with an equal sign (=). This particular formula consists of a function name (here, AVERAGE) and its arguments (here, B2:B11).

In the normal course of events, after you have finished entering a formula into a worksheet cell, Excel responds as follows:

  • The formula itself, including any function and arguments involved, appears in the formula box.
  • The result of the formula—in this case, what the function returns—appears in the cell where you entered the formula.
  • The precise result of the formula might or might not appear in that cell, depending on the cell format that you have specified. For example, if you have limited the number of decimal places that can show up in the cell, the result may appear less precise.

I used the phrase “normal course of events” just now because there are steps you sometimes take to override them (see Figure 2.3).

Figure 2.3

The formula bar contains the name box, on the left, and the formula box, on the right.

Figure 2.3

Notice these three aspects of the worksheet in Figure 2.3: The formula itself is visible in the formula box, its result is visible in cell B13, and its result can also be seen with a different appearance in cell B15.

Visible Formulas

The formula itself appears in the formula box. But if you wanted, you could set the protection for cell B13, or B15, to Hidden. Then, if you also protect the worksheet, the formula would not appear in the formula box. Usually, though, the formula box shows you the formula or the static value you’ve entered in the cell.

Visible Results

The result of the formula appears in the cell where the formula is entered. In Figure 2.3, you see the mean price per gallon for 10 gas stations in cells B13 and B15. But you could instead see the formulas in the cells. There is a Show Formulas toggle button in the Formula Auditing section of the Ribbon’s Formulas tab. Click it to change from values to formulas and back to values. Another, slower way to toggle the display of values and formulas is to click the File tab and choose Options from the navigation bar. Click Advanced in the Excel Options window and scroll down to the Display Options for This Worksheet area. Fill the check box labeled Show Formulas in Cells Instead of Their Calculated Results.

Same Result, Different Appearance

In Figure 2.3, the same formula is in cell B15 as in cell B13, but the formula appears to return a different result. Actually, both formulas return the value 3.697. But cell B13 is formatted to show currency, and United States currency formats display two decimal values only, by convention. So, if you call for the currency format and your operating system is using U.S. currency conventions, the display is adjusted to show just two decimals. You can change the number of decimals displayed if you wish, by selecting the cell and then clicking either the Increase Decimal or the Decrease Decimal button in the Number group on the Home tab.

Minimizing the Spread

The mean has a special characteristic that makes it more useful for certain intermediate and advanced statistical analyses than the median and the mode. That characteristic has to do with the distance of each individual observation from the mean of those observations.

Suppose that you have a list of 10 numbers—say, the ages of all your close relatives. Pluck another number out of the air. Subtract that number from each of the 10 ages and square the result of each subtraction. Now, find the total of all 10 squared differences.

If the number that you chose, the one that you subtracted from each of the 10 ages, happens to be the mean of the 10 ages, then the total of the squared differences is minimized (thus the term least squares). That total is smaller than it would be if you chose any number other than the mean. This outcome probably seems a strange thing to care about, but it turns out to be an important characteristic of many statistical analyses, as you’ll see in later chapters of this book.

Here’s a concrete example. Figure 2.4 shows the height of each of 10 people in cells A2:A11.

Figure 2.4

Columns B, C, and D are reserved for values that you supply.

Figure 2.4

Using the workbook for Chapter 2 (see www.informit.com/title/9780789759054 for download information), you should fill in columns B, C, and D as described later in this section. The cells B2:B11 in Figure 2.4 then contain a value—any numeric value—that’s different from the actual mean of the 10 observations in column A. You will see that if the mean is in column B, the sum of the squared differences in cell D13 is smaller than if any other number is in column B.

To see that, you need to have made Solver available to Excel.

About Solver

Solver is an add-in that comes with Microsoft Excel. You can install it from the factory disc or from the software that you downloaded to put Excel on your computer. Solver helps you backtrack to underlying values when you want them to result in a particular outcome.

For example, suppose that you have 10 numbers on a worksheet, and their mean value is 25. You want to know what the tenth number must be in order for the mean to equal 30 instead of 25. Solver can do that for you. Normally, you know your inputs and you’re seeking a result. When you know the result and want to find the necessary values of the inputs, Solver provides one way to do so.

The example in the prior paragraph is trivially simple, but it illustrates the main purpose of Solver: You specify the outcome and Solver determines the input values needed to reach the outcome.

You could use another Excel tool, Goal Seek, to solve the latter problem. But Solver offers you many more options than does Goal Seek. For example, using Solver, you can specify that you want an outcome maximized or minimized, instead of solving for a particular outcome (as required by Goal Seek). That’s relevant here because we want to find a value that minimizes the sum of the squared differences.

Finding and Installing Solver

It’s possible that Solver is already installed and available to Excel on your computer. To use Solver in Excel 2007 through 2016, click the Ribbon’s Data tab and find the Analysis group. If you see Solver there, you’re all set. (In Excel 2003 or earlier, check for Solver in the Tools menu.)

If you don’t find Solver on the Ribbon or in the Tools menu, take these steps in Excel 2007 through 2016:

  1. Click the Ribbon’s File tab and choose Options.
  2. Choose Add-Ins from the Options navigation bar.
  3. At the bottom of the View and Manage Microsoft Office Add-Ins window, make sure that the Manage drop-down is set to Excel Add-Ins, and then click Go.
  4. The Add-Ins dialog box appears. If you see Solver Add-in listed, fill its check box and click OK.

You should now find Solver in the Analysis group on the Ribbon’s Data tab.

If you’re using Excel 2003 or earlier, start by choosing Add-Ins from the Tools menu. Then complete step 4 in the preceding list.

If you didn’t find Solver in the Analysis group on the Data tab (or on the Tools menu in earlier Excel versions), and if you did not see it in the Add-Ins dialog box in step 4, then Solver was not installed with Excel. You will have to rerun the installation routine, and you can usually do so via the Programs item in the Windows Control Panel.

The sequence varies according to the operating system you’re running, but you should choose to change features for Microsoft Office. Expand the Excel option by clicking the plus sign by its icon and then do the same for Add-ins. Click the drop-down by Solver and choose Run from My Computer. Complete the installation sequence. When it’s through, you should be able to make the Solver add-in available to Excel using the sequence of four steps provided earlier in this section.

Setting Up the Worksheet for Solver

With the actual observations in A2:A11, as shown in Figure 2.4, continue by taking these steps:

  1. Enter any number in cell G2. It is 0 in Figure 2.4, but you could use 10 or 1066 or 3.1416 if you prefer. When you’re through with these steps, you’ll find the mean of the values in A2:A11 has replaced the value you now begin with in cell G2.
  2. In cell B2, enter this formula:
  3. Copy and paste the formula in B2 into B3:B11. Because the dollar signs in the cell address make it a fixed reference, you will find that each cell in B2:B11 contains the same formula. And because the formulas point to cell G2, whatever number is there also appears in B2:B11.
  4. In cell C2, enter this formula:
  5. Copy and paste the formula in C2 into C3:C11. The range C2:C11 now contains the differences between each individual observation and whatever value you chose to put in cell G2.
  6. In cell D2, enter the following formula, which uses the caret as an exponentiation operator to return the square of the value in cell C2:
  7. Copy and paste the formula in D2 into D3:D11. The range D2:D11 now contains the squared differences between each individual observation and whatever number you entered in cell G2.
  8. To get the sum of the squared differences, enter this formula in cell D13:
  9. Now start Solver. With cell D13 selected, click the Data tab and locate the Analysis group. Click Solver to bring up the dialog box shown in Figure 2.5.

    Figure 2.5

    The Set Objective field should contain the cell you want Solver to maximize, minimize, or set to a specific value.

    Figure 2.5
  10. You want to minimize the sum of the squared differences, so choose the Min option button.
  11. Because D13 was the active cell when you started Solver, it is the address that appears in the Set Objective field. Click in the By Changing Variable Cells box and then click in cell G2. This establishes the cell whose value Solver will modify.
  12. Click Solve.

Solver now iterates through a sequence of values for cell G2. It stops when its internal decision-making rules determine that it has found a minimum value for cell D13 and that testing more values in cell G2 won’t help. At that point Solver displays a Solver Results dialog box. Choose to keep Solver’s solution or to restore the original values, and click OK.

Using the data given in Figure 2.4, Solver finishes with a value of 68.8 in cell G2 (see Figure 2.6). Because of the way that the worksheet was set up, that’s the value that now appears in cells B2:B11, and it’s the basis for the differences in C2:C11 and the squared differences in D2:D11. The sum of the squared differences in D13 is minimized, and the value in cell G2 that’s responsible for the minimum sum of the squared differences—or, in more typical statistical jargon, least squares—is the mean of the values in A2:A11.

Figure 2.6

Compare cell G2 with the average of the values in A2:A11.

Figure 2.6

A few comments on this demonstration:

  • It works with any set of real numbers and a set of any size. Supply some numbers, total their squared differences from some other number, and then tell Solver to minimize that sum. The result will always be the mean of the original set.
  • This is a demonstration, not a proof. The proof that the squared differences from the mean sum to a smaller total than from any other number is not complex and it can be found in a variety of sources.
  • This discussion uses the terms differences and squared differences. You’ll find that it’s more common in statistical analysis to speak and write in terms of deviations and squared deviations.

This has to be the most roundabout way of calculating a mean ever devised. The AVERAGE() function, for example, is lots simpler. But the exercise using Solver in this section is important for two reasons:

  • Understanding other concepts, including correlation, regression, and the general linear model, will come much easier if you have a good feel for the relationship between the mean of a set of scores and the concept of minimizing squared deviations.
  • If you have not yet used Excel’s Solver, you have now had a glimpse of it, although in the context of a problem solved much more quickly using other tools.

I have used a very simple statistical function, AVERAGE(), as a context to discuss some basics of functions and formulas in Excel. These basics apply to all Excel’s mathematical and statistical functions, and to many functions in other categories as well. You’ll need to know about some other aspects of functions, but I’ll pick them up as we get to them: They’re much more specific than the issues discussed in this chapter.

It’s time to get on to the next measure of central tendency: the median.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020