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.

Performing Magic with Array Formulas 18<br />

Summing the n largest values in a range<br />

The following array formula returns the sum of the 10 largest values in a range named Data:<br />

{=SUM(LARGE(Data,ROW(INDIRECT(“1:10”))))}<br />

The LARGE function is evaluated 10 times, each time with a different second argument (1, 2, 3, and so on<br />

up to 10). The results of these calculations are stored in a new array, and that array is used as the argument<br />

for the SUM function.<br />

To sum a different number of values, replace the 10 in the argument for the INDIRECT function with<br />

another value.<br />

If the number of cells to sum is contained in cell C17, use the following array formula, which uses the concatenation<br />

operator (&) to create the range address for the INDIRECT function:<br />

{=SUM(LARGE(Data,ROW(INDIRECT(“1:”&C17))))}<br />

To sum the n smallest values in a range, use the SMALL function instead of the LARGE function.<br />

Computing an average that excludes zeros<br />

Figure 18.2 shows a simple worksheet that calculates average sales. The formula in cell B14 is<br />

=AVERAGE(B5:B12)<br />

FIGURE 18.2<br />

The calculated average includes cells that contain a 0.<br />

Two of the sales staff had the week off, however, so including their 0 sales in the calculated average doesn’t<br />

accurately describe the average sales per representative.<br />

NOTE<br />

The AVERAGE function ignores blank cells, but it does not ignore cells that contain 0.<br />

The following array formula returns the average of the range but excludes the cells containing 0:<br />

{=AVERAGE(IF(B5:B120,B5:B12))}<br />

335

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

Saved successfully!

Ooh no, something went wrong!