ARRAYFORMULA Function – Google Sheets

The ARRAYFORMULA function spreads its output across multiple rows and columns. You can use this function to repeat non-array functions such as SUM, PRODUCT, or AVERAGE.

As with other functions that generate arrays, such as FILTER and QUERY, the output needs space to expand below and right. Keep this in mind, so you do not overwrite other data.

Tip: Use the shortcut key combination of Ctrl+Shift+Enter to wrap your function inside ARRAYFORMULA.

Syntax

=ARRAYFORMULA(array_formula)

  • arrayformula – One of the following:
    • A range
    • Mathematical expression with ranges of the same size
    • A function that returns more than one cell

Related Functions

ARRAY_CONSTRAIN – Limits the output of an array

QUERY – SQL-like function that you can use to return more complex arrays

SUMPRODUCT – Calculates the sum of two or more ranges of multiplied values. If using ARRAYFORMULA to extend simple multiplication, consider this function instead.

Video Tutorial

Thumbnail for the ARRAYFORMULA YouTube Video
YouTube Video Explaining How to Use ARRAYFORMULA

Examples

Source table for ARRAYFORMULA with four columns
Source Data for All Examples

The table pictured above is the source data used for all examples. It represents a company’s inventory that consists of different types of items, number of cases, number of items per case, and location. As the data contains a mix of numbers and strings, it will make for easy examples of using the ARRAYFORMULA.

Example 1 – Returning a Column

=ARRAYFORMULA(A1:A13)

One column output from ARRAYFORMULA
Just Column A

You can use a simple cell range as the only input, and the function outputs just that column as shown on the left. A cell range is not a typical use of the function but serves to illustrate how it writes data into more than one cell.

You may want to return unmodified data if you need to duplicate a table of data while leaving the source intact. When you update the source data, the output of this function will update accordingly.

Example 2 – Returning a Row

=ARRAYFORMULA(A2:D2)

Output from the ARRAYFORMULA that is one row
Just Row 2

The image above shows another simple illustration where we use the function to output data without further manipulation. However, this example shows that the data can work horizontally on rows and vertically on columns.

Example 3 – Add a Column with Multiplication

=ARRAYFORMULA((B2:B13)*(C2:C13))

A column of data added with ARRAYFORMULAto source table
A Calculated Column Appended to the Source Table

Using the ARRAYFORMULA to extend multiplication down a column is an excellent example of the power of this function. This one formula accomplishes the same thing as repeating a multiplication formula 12 times, once in each row. If you delete rows from the table, the formula will automatically adjust.

Note that each range in the input needs to be the same size. In this example, both ranges span 12 rows. If you have a very long table, you could drop the ending row values such as B2:B and C2:C. Removing the ending row numbers would extend the formula to the bottom of the spreadsheet.

Example 4 – Multiply Values if a Word Matches

=ARRAYFORMULA(IF(D2:D13="North",(B2:B13)*(C2:C13),0))

A column of data added with ARRAYFORMULAto source table with zeros for South and East warehouses
A Calculated Column Only If Value in D is North

The formula used for the array_formula input can be more complex if needed. In this case, we have added an IF statement to limit the multiplication to only the North warehouse.

Example 5 – Join Words and Numbers

=ARRAYFORMULA("The "&D2:D13&" warehouse has "&B2:B13&" cases of "&A2:A13&"s.")

Output from ARRAYFORMULA showing values concatenated
Values Joined Using &

The formula does not need to be mathematical. In this example, we use it to join words and numbers to create simple phrases. Using the & sign is similar to the CONCATENATE formula.

Live Example in Sheets

Go to this spreadsheet for examples of the ARRAYFORMULA function shown above that you can study and use anywhere you want.

Leave a Comment