Excel Excel Stuff Excel Tips and Tricks Array Formula Examples
Excel Excel Stuff Excel Tips and Tricks Array Formula Examples
An array formula works on whole ranges of the worksheet at once. Suppose that we have two ranges of
numbers:
1 5
2 6
3 7
4 8
Now, suppose that as an input to a formula, we need to know the product of the corresponding values in
each array (e.g., 1*5, 2*6, etc). We can create an array of these products with A1:A4*B1:B4 (assuming the
original values are in those ranges). The resulting array would be {5,12,21,32}. The example to the right
shows how this works.
Suppose that we need to know the results of dividing each number in K4:K13 by L4:L13. We could create
in M4 the formula: =K4/L4 and then copy this down. That would give us the result that we need.
Alternatively, we could create an array. First select M4:M13. Now, type in the formula: =K4:K13/L4:L13
and then hold down Ctrl and Shift while pressing the Enter key. If you look at one of the cells in the array,
you will see that the formula is: {=K4:K13/L4:L13}. Notice that Excel has added the curly brackets
indicating that this is an array formula. If you were to just press the Enter key (neglecting to hold down
Ctrl and Shift) you would get only the value in M4.
So, what's the advantage? Well, in this case nothing really. However, as we'll see, array formulas are much
more efficient than regular formulas in two ways:
1) They save space in the worksheet. Using array formulas we can eliminate columns showing
intermediate results. This also makes the worksheet easier to read because it isn't cluttered up by
unnecessary information.
2) They calculate more quickly than the equivalent series of individual formulas.
Follow along with the examples, and your spreadsheet skills will improve markedly.
Resulting
Number Divisor Array
10 10 1
20 10 2
30 10 3
40 10 4
50 10 5
60 10 6
70 10 7
80 10 8
90 10 9
100 10 10
Weight Score
0.1 95 What this spreadsheet does:
0.2 85
This sheet demonstrates how to calculate a weighted average, variance, and standard d
0.4 75
array formulas. Note that I could have used the SumProduct function to calculate the
0.2 65 average, but Excel has no function to calculate standard deviation when the weights ar
0.1 55
Weighted Average 75 Had I used normal formulas, I would have had to add a column or two to do intermedi
Variance 120 The array functions are much more efficient in terms of speed of calculation and in the
Standard Deviation 10.95 spreadsheet space they consume.
Weighted Average:
Array functions work on whole ranges at a time, rather than individual cells. The weig
the most simple. The formula is =SUM(A2:A6*B2:B6). First, the formula says "take
A2:A6 and multiply it by the corresponding value in B2:B6. This creates an array (or
Sum function simply calculates the total of all of the elements of the array.
Variance:
This is a bit more complicated, but the logic is similar. The formula is =SUM((B2:B6
AVERAGE(B2:B6))^2*A2:A6). To calculate the variance, we subtract the average of
outcomes from each possible outcome, square the difference, multiply by the probabli
and finally sum the results. Let's break this formula down to its parts in order of calcu
The first part takes each value in B2:B6 and subtracts the average of these values. The
of deviations from the mean. Next, each value in this array is squared resulting in an a
deviations from the mean. Now, we calculate a weighted average of these squared dev
multiplying each squared deviation by its probability of occurance and summing the re
Standard Deviation:
The standard deviation is calculated by finding the square root of the variance. The ea
this would be to use =sqrt(B8), but we don't have to use a cell for the variance calculat
we only care about the standard deviation, so we would use the formula: =SQRT(SUM
AVERAGE(B2:B6))^2*A2:A6)). This is the same formula as before, but we have add
function around the whole thing.
ge, variance, and standard deviation using
ct function to calculate the weighted
viation when the weights are unequal.
e formula is =SUM((B2:B6-
, we subtract the average of all possible
ce, multiply by the probablility of occurance,
to its parts in order of calculation:
ormula is:
This is less complicated if we break it down
Historical stock prices provided by CSI, Inc. Historical mutual fund and industry prices provided by Media General Financial
GM) to each other and a broad market index (S&P 500).
r the five-year period, compound average monthly
s, coefficient of variation of monthly returns, and betas.