Statistics for Beginners – Introduction to Excel Array Formulas and Functions

(Basic Statistics for Citizen Data Scientist)

Array Formulas and Functions

Excel also allows you to define a formula that assigns values to a range of cells at the same time. These are called array formulas and they will be used quite often throughout this website.

Array formulas

We now show how to create formulas that modify multiple cells at the same time.

Example 1: Calculate the revenues for each item in the worksheet of Figure 1.

Array formula Excel

Figure 1 – Array formula

Given that the revenue for each item is unit price times quantity, we can enter the formula =B4*C4 in cell D4 and then copy this formula into cells D5, D6 and D7 (e.g. by clicking on cell D4, pressing Ctrl-C, then highlighting the range D5:D7 and pressing Ctrl-V, or by highlighting the range D4:D7 and pressing Ctrl-D).

Another way to do this is via an array formula, using the following steps:

  1. Highlight the range D4:D7
  2. Enter the array formula =B4:B7*C4:C7
  3. Press Ctrl-Shft-Enter (i.e. hold down the Ctrl and Shift keys and press the Enter key)

It is essential to press Ctrl-Shft-Enter (step 3) and not simply Enter as for an ordinary formula. Note that the formula that appears in the formula bar is {=B4:B7*C4:C7}. The curly brackets indicate that this is an array formula. If the range B4:B7 is given the name UnitPrice and C4:C7 is given the name Quantity, then the array formula can be entered as =UnitPrice*Quantity (step 2);

The array formula appears in all four cells in the range D4:D7. To make changes to the formula you must edit the entire range and not just one, two or three of these cells. Similarly, you can’t copy or delete a part of the range but must copy or delete the entire range. If you attempt to modify a part of the range you will receive an error message. If you get stuck and get a series of such error messages you just need to press the escape key Esc to recover.

You can erase a range that contains an array formula by highlighting the entire range and pressing the Delete key. You can write over the array function replacing it by a value or another formula. The important thing is to use the entire range and not a part of the range.

You can also extend the range covered by an array formula by clicking on any one of the four corners of the range and then highlighting a range that includes the original range. Finally, you click anywhere on the formula bar and press Ctrl-Shft-Enter.

Note too that you can also use array formulas such as {=SUM(B4:B7*C4:C7)}. This returns the value which is the sum of the revenues of the four types of equipment. Even though this formula returns a single value, and so may be placed in a single cell such as D8, it must be entered as an array formula (since the formula contains an embedded array formula). This means that you need to type =SUM(B4:B7*C4:C7) and then press Ctrl-Shft-Enter. If you forget to press Ctrl-Shft-Enter and only press Enter, you will get an error message.

Array functions

A few of Excel’s built-in functions are array functions, where the output of the function is an array. These functions are managed as described above for array formulas.

Example 2: Change the data range in columns A and B of Figure 2 into an equivalent row range.

Array function Excel

Figure 2 – Array function

This can be accomplished by means of Excel’s TRANSPOSE array function using the following steps:

  1. Highlight the output range D3:I4
  2. Enter the array formula =TRANSPOSE(A3:B8)
  3. Press Ctrl-Shft-Enter

Note that the output range (step 1) must be of the right size. In this case, the input range is 6 rows by 2 columns, and so the output range must be 2 rows by 6 columns. If the highlighted range is too small the output will be truncated, while if it is too large the extra cells will be filled with the error value #N/A.

As for array formulas the formula bar contains the array formula enclosed in curly brackets. As always, it is essential to press Ctrl-Shft-Enter.

 

Excel formula for Beginners – How to Count cells equal to one of many things

 

Statistics for Beginners – Introduction to Excel Array Formulas and Functions

Personal Career & Learning Guide for Data Analyst, Data Engineer and Data Scientist

Applied Machine Learning & Data Science Projects and Coding Recipes for Beginners

A list of FREE programming examples together with eTutorials & eBooks @ SETScholars

95% Discount on “Projects & Recipes, tutorials, ebooks”

Projects and Coding Recipes, eTutorials and eBooks: The best All-in-One resources for Data Analyst, Data Scientist, Machine Learning Engineer and Software Developer

Topics included: Classification, Clustering, Regression, Forecasting, Algorithms, Data Structures, Data Analytics & Data Science, Deep Learning, Machine Learning, Programming Languages and Software Tools & Packages.
(Discount is valid for limited time only)

Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.

Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners

Please do not waste your valuable time by watching videos, rather use end-to-end (Python and R) recipes from Professional Data Scientists to practice coding, and land the most demandable jobs in the fields of Predictive analytics & AI (Machine Learning and Data Science).

The objective is to guide the developers & analysts to “Learn how to Code” for Applied AI using end-to-end coding solutions, and unlock the world of opportunities!