# Dynamic array formulas in Excel

Dynamic Arrays are the biggest change to Excel formulas in years. Maybe the biggest change ever. This is because Dynamic Arrays let you easily work with multiple values at the same time in a formula. For many users, it will be the first time they understand and use array formulas.

This is a big upgrade and welcome change. Dynamic Arrays will solve some really hard problems in Excel, and fundamentally change the way worksheets are designed and constructed.

### Availability

Dynamic arrays and the new functions below are only available Excel 365. Excel 2016 and Excel 2019 do not offer dynamic array formula support. For convenience, I'll use "Dynamic Excel" (Excel 365) and "Traditional Excel" (2019 or earlier) to differentiate versions below.

### New functions

As part of the dynamic array update, Excel now includes 8 new functions which directly leverage dynamic arrays to solve problems that are traditionally hard to solve with conventional formulas. Click the links below for details and examples for each function:

Function | Purpose |
---|---|

FILTER | Filter data and return matching records |

RANDARRAY | Generate array of random numbers |

SEQUENCE | Generate array of sequential numbers |

SORT | Sort range by column |

SORTBY | Sort range by another range or array |

UNIQUE | Extract unique values from a list or range |

XLOOKUP | Modern replacement for VLOOKUP |

XMATCH | Modern replacement for the MATCH function |

Video: New dynamic array functions in Excel (about 3 minutes).

Note: XLOOKUP and XMATCH were not in the original group of new dynamic array functions, but they run great on the new dynamic array engine. XLOOKUP replaces VLOOKUP and offers a modern, flexible approach that takes advantage of arrays. XMATCH is an upgrade to the MATCH function, providing new capabilities to INDEX and MATCH formulas.

### Example

Before we get into the details, let's look at a simple example. Below we are using the new UNIQUE function to extract unique values from the range B5:B15, with a *single* formula entered in E5:

=UNIQUE(B5:B15) // return unique values in B5:B15

The result is a list of the five unique city names, which appear in E5:E9.

Like all formulas, UNIQUE will update automatically when data changes. Below, Vancouver has replaced Portland on row 11. The result from UNIQUE now includes Vancouver:

### Spilling - one formula, many values

In Dynamic Excel, formulas that return multiple values will "spill" these values directly onto the worksheet. This will immediately be more logical to formula users. It is also a fully dynamic behavior – when source data changes, spilled results will immediately update.

The rectangle that encloses the values is called the "spill range". You will notice that the spill range has special highlighting. In the UNIQUE example above, the spill range is E5:E10.

When data changes, the spill range will expand or contract as needed. You might see new values added, or existing values disappear. In this way, a spill range is a new kind of dynamic range.

*Note: when spilling is blocked by other data, you'll see a #SPILL error. Once you make room for the spill range, the formula will automatically spill.*

Video: Spilling and the spill range

### Spill range reference

To refer to a spill range, use a hash symbol (#) after the first cell in the range. For example, to reference the results from the UNIQUE function above use:

=E5# // reference UNIQUE results

This is the same as referencing the entire spill range, and you'll see this syntax when you write a formula that refers to a complete spill range.

You can feed a spill range reference into other formulas directly. For example, to count the number of cities returned by UNIQUE, you can use:

=COUNTA(E5#) // count unique cities

When the spill range changes, the formula will reflect the latest data.

### Massive simplification

The addition of new dynamic array formulas means certain formulas can be drastically simplified. Here are a few examples:

- Extract and list unique values (before | after)
- Count unique values (before | after)
- Filter and extract records (before | after)
- Extract partial matches (before | after)

### The power of one

One of the most powerful benefits of the "one formula, many values" approach is less reliance on absolute or mixed references. As a dynamic array formula spills results onto the worksheet, references remain unchanged, but the formula generates correct results.

For example, below we use the FILTER function to extract records in group "A". In cell F5, a single formula is entered:

=FILTER(B5:D11,B5:B11="a") // references are relative

Notice both ranges are unlocked relative references, but the formula works perfectly.

This is a huge benefit for many users, because it makes the process of writing formulas so much simpler. For another good example, see the multiplication table below.

### Chaining functions

Things get really interesting when you chain together more than one dynamic array function. Perhaps you want to sort the results returned by UNIQUE? Easy. Just wrap the SORT function around the UNIQUE function like this:

As before, when source data changes, new unique results automatically appear, nicely sorted.

### Native behavior

It's important to understand that dynamic array behavior is a *native and deeply integrated. *When *any* formula returns multiple results, these results will spill into multiple cells on the worksheet. This includes older functions not originally designed to work with dynamic arrays.

For example, in Traditional Excel, if we give the LEN function a *range* of text values, we'll see a *single* result. In Dynamic Excel, if we give the LEN function a range of values, we'll see *multiple* results. This screen below shows the old behavior on the left and the new behavior on the right:

This a huge change that can affect all kinds of formulas. For instance, the VLOOKUP function is designed to fetch a single value from a table, using a column index. However, in Dynamic Excel, if we give VLOOKUP more than one column index using an array constant like this:

=VLOOKUP("jose",F7:H10,{1,2,3},0)

VLOOKUP will return multiple columns:

In other words, even though VLOOKUP was never designed to return multiple values, it can now do so, thanks to new formula engine in Dynamic Excel.

### All formulas

Finally, note that dynamic arrays work with *all formulas* not just functions. In the example below cell C5 contains a single formula:

=B5:B14*C4:L4

The result spills into a 10 by 10 range that includes 100 cells:

Note: In Traditional Excel, you can see multiple results returned by array formula if you use F9 to inspect the formula. But unless you are entering the formula as a multi-cell array formula, only one value will display on the worksheet.

### Arrays go mainstream

With the rollout of dynamic arrays, the word "array" is going to pop up much more often. In fact, you may see "array" and "range" used almost interchangeably. You'll see arrays in Excel enclosed in curly braces like this:

{1,2,3} // horizontal array {1;2;3} // vertical array

Array is a programming term that refers to a list of items that appear in a particular order. The reason arrays come up so often in Excel formulas is that arrays can perfectly express the values in a range of cells.

Video: What is an array?

### Array operations become important

Because Dynamic Excel formulas can easily work with multiple values, array operations will become more important. The term "array operation" refers to an expression that runs a logical test or math operation on an array. For example, the expression below tests if values in B5:B9 are equal to "ca"

=B5:B9="ca" // state = "ca"

because there are 5 cells in B5:B9, the result is 5 TRUE/FALSE values in an array:

{FALSE;TRUE;FALSE;TRUE;TRUE}

The array operation below checks for amounts greater than 100:

=C5:C9>100 // amounts > 100

The final array operation combines test A and test B in a single expression:

=(B5:B9="ca")*(C5:C9>100) // state = "ca" and amount > 100

Note: Excel automatically coerces the TRUE and FALSE values to 1 and 0 during the math operation.

To bring this back to dynamic array formulas in Excel, the example below demonstrates how we can use exactly the same array operation inside the FILTER function as the *include* argument:

FILTER returns the two records where state = "ca" and amount > 100.

For a demonstration, see: How to filter with two criteria (video).

### New and old array formulas

In Dynamic Excel, there is no need to enter array formulas with control + shift + enter. When a formula is created, Excel checks if the formula might return multiple values. If so, it will automatically be saved as a dynamic array formula, but you will not see curly braces. The example below shows a typical array formula entered in Dynamic Excel:

If you open the same formula in Traditional Excel, you'll see curly braces:

Going the other direction, when a "traditional" array formula is opened in Dynamic Excel, you will see the curly braces in the formula bar. For example, the screen below shows a simple array formula in Traditional Excel:` `

However, if you re-enter the formula with no changes, the curly braces are removed, and the formula returns the same result:

The bottom line is that array formulas entered with control + shift + enter (CSE) still work to maintain compatibility, but you shouldn't need to enter array formulas with CSE in Dynamic Excel.

### The @ character

With the introduction of dynamic arrays, you're going to see the @ character appear more often in formulas. The @ character enables a behavior known as "implicit intersection". Implicit intersection is a logical process where many values are reduced to one value.

In Traditional Excel, implicit intersection is a silent behavior used (when necessary) to reduce multiple values to a single result in one cell. In Dynamic Excel, it is not typically needed, since multiple results can spill onto the worksheet. When it is needed, implicit intersection is invoked manually with the @ character.

When opening spreadsheets created an older version of Excel, you may see the @ character added automatically to existing formulas that have the *potential* to return many values. In Traditional Excel, a formula that returns multiple values won't spill on the worksheet. The @ character forces this same behavior in Dynamic Excel so that the formula behaves the same way and returns the same result as it did in the original Excel version.

In other words, the @ is added to prevent an older formula from spilling multiple results onto the worksheet. Depending on the formula, you may be able to remove the @ character and the behavior of the formula will not change.

### Summary

- Dynamic Arrays will make certain formulas much easier to write.
- You can now filter matching data, sort, and extract unique values easily with formulas.
- Dynamic Array formulas can be chained (nested) to do things like filter and sort.
- Formulas that return more than one value will automatically spill.
- It is not necessary to use Ctrl+Shift+Enter to enter an array formula.
- Dynamic array formulas are only available in Excel 365.

## Download 100+ Important Excel Functions

Get over 100 Excel Functions you should know in one handy PDF.