18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Part II<br />

Working with Formulas and Functions<br />

Total occurrences in a range<br />

To count the total number of occurrences of a string within a range of cells, use the following array formula:<br />

{=(SUM(LEN(Data))-SUM(LEN(SUBSTITUTE(Data,Text,””))))/<br />

LEN(Text)}<br />

If the Text cell contains the character “B”, the formula returns 7 because the range contains seven instances<br />

of the string. This formula is case sensitive.<br />

The following array formula is a modified version that is not case sensitive:<br />

{=(SUM(LEN(Data))-SUM(LEN(SUBSTITUTE(UPPER(Data),<br />

UPPER(Text),””))))/LEN(Text)}<br />

Counting the number of unique values<br />

The following array formula returns the number of unique values in a range named Data:<br />

{=SUM(1/COUNTIF(Data,Data))}<br />

NOTE<br />

The preceding formula is one of those “classic” Excel formulas that gets passed around the<br />

Internet. I don’t think anyone knows who originated it.<br />

Useful as it is, this formula does have a serious limitation: If the range contains any blank cells, it returns an<br />

error. The following array formula solves this problem:<br />

{=SUM(IF(COUNTIF(Data,Data)=0,””,1/COUNTIF(Data,Data)))}<br />

CROSS-REF<br />

To find out how to create an array formula that returns a list of unique items in a range, refer<br />

to Chapter 18.<br />

ON the CD-ROM<br />

The companion CD-ROM contains a workbook that demonstrates this technique. The file is<br />

named count unique.xlsx.<br />

Creating a frequency distribution<br />

A frequency distribution basically comprises a summary table that shows the frequency of each value in a range.<br />

For example, an instructor may create a frequency distribution of test scores. The table would show the count<br />

of A’s, B’s, C’s, and so on. Excel provides a number of ways to create frequency distributions. You can<br />

n<br />

n<br />

n<br />

n<br />

Use the FREQUENCY function<br />

Use the Analysis ToolPak add-in<br />

Create your own formulas<br />

Use a pivot table<br />

ON the CD-ROM<br />

A workbook that demonstrates these four techniques appears on the companion CD-ROM. The<br />

file is named frequency distribution.xlsx.<br />

260

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!