Excel Dynamic Arrays: Course Notes
Excel Dynamic Arrays: Course Notes
Dynamic Arrays
Course Notes
Leila Gharani (Microsoft Excel MVP)
XelPlus.com 2
What are Dynamic & Spilled Arrays?
Glossary of Terms
XelPlus.com 3
Course Road Map
Basic Dynamic Arrays & Excel’s New Calculation
Engine (Hash / Spilled referencing)
Advanced
The ONE Theory you NEED to Use
FILTER Like a Pro
Expert
Advanced to Expert: How Arrays
Really Work
XelPlus.com 4
Table of Contents
Dynamic Arrays & Spill Behavior ------- 6
@ Prefix ------- 13
XelPlus.com 5
Formulas Now Spill
MAJOR CHANGE IN THE CALC ENGINE: SPILL RANGE
Any formula that returns many results, will now spill to many cells.
Example: Typing in =A6:C20 and pressing Enter in cell G6 will spill the values
to the cells below.
The formula “lives” only in cell G6. –i.e. only that cell is editable. The formula in the
cells below G6 are greyed out. To delete the entire G6:I20 range or cut & paste it
somewhere else you just need to delete or cut the value in G6.
The highlighted blue border appears if you are in a cell inside the spilled range. It
disappears if you move outside the spilled range.
If there are existing values in the cells of the output range – you will receive the
new #SPILL! Error. This means the values can’t spill because something is blocking
it. Removing the obstruction will automatically spill the formula.
XelPlus.com 6
Important Points on Spill Behavior
If the spilled range is referencing an Excel Table, the range will automatically
expand or shrink as the tables size changes. In the example below, if we add more
data to the Excel Table, the spilled array in range G28 will automatically expand to
include these.
Spilled array formulas are not supported inside Excel Tables. You need to use
these outside the table.
To dynamically reference a spilled range, you need to refer to the first cell (where
the formula lives) and put in the hash (#) sign. In the example above you can input
=G28# in L28 to reference the entire spilled range.
For Advanced Excel Users: Microsoft will keep CSE formulas going forward for
compatibility purposes, but they advise to stop using these in future Excel
versions and using the new DA-aware Excel functions.
For Advanced Excel Users: You no longer need to use Control + Shift + Enter (CSE)
to input array values or work with array formulas like Transpose and Frequency.
XelPlus.com 7
FILTER Function (The New Power Lookup)
Situations you’ll be needing this:
• You need to show multiple results for one or more lookup values
• You’d like to have a filter that automatically refreshes without the need to
press the refresh button
• You’d like to sum or count the filtered values (can be used as an alternative
to SUMIFS or COUNTIFS)
The columns that you’d like Optional: If Filter doesn’t find anything, what would
included in the result. This can be you like returned. For example: “No Data”. This is an
the entire data set or a part of the optional argument, but if you don’t specify it and
original data set. Filter doesn’t find any results, you will get a #CALC!
Error.
Example
XelPlus.com 8
SORT & SORTBY Functions
Situations you’ll be needing these:
To define the sort order for multiple columns, use curly brackets like in
this example: =SORT(A6:C20,{1,2},{1,-1}) This means column A is sorted
in ascending order and then column B in descending order.
XelPlus.com 9
UNIQUE Function
Situations you’ll be needing this:
• You’d like to get a unique list of items from your data set. The result will
include each item from the data set only once in the final list.
• You’d like to get a distinct list of items from your data set. The result will
show items that occur only once in the data set.
• You’d like your unique list to update automatically without the need to
refresh a query.
Example
XelPlus.com 10
SEQUENCE Function
Situations you’ll be needing this:
Example
XelPlus.com 11
RANDARRAY Function
Situations you’ll be needing this:
Basic Example
XelPlus.com 12
@ For Compatibility
This was first called the SINGLE function. It was changed to the @
symbol in February 2019. Main reason: @ symbol is less confusing and
easier to apply than a whole new function.
@(Formula or Reference)
If you open an old file in DA Excel, you will see the @ symbol for array
formulas. If you save the file and re-open in legacy Excel, the @ symbol
disappears in legacy Excel.
XelPlus.com 13
RULES for Dynamic Arrays
1 If a formula delivers a single answer, it will return a single
answer in one cell.
3 The actual formula lives only in the first cell of the spilled
range. The rest are based off the first one.
4 If something is in a cell below the spill range, you will get the
new #spill error (your values below will never be overwritten).
Once the values are removed the formula will spill
automatically.
XelPlus.com 14
Forward Compatibility (Legacy to DA)
Compatibility has been carefully addressed by Microsoft
with this change. Overall you don’t have to worry about it.
XelPlus.com 15
Backward Compatibility (DA to Legacy)
How about opening DA files in Older versions of Excel?
The only major impact is when new formulas and spilled referencing have
been used. The invalid name error is returned.
XelPlus.com 16
DA Impact on Legacy
Formulas
1 Forward Compatibility: Older files will work just as well in
DA Excel version. You might see the @ prefix for some of
your formulas.
XelPlus.com 17
DA Impact on Legacy
Features
1 Data Validation can take advantage of spill references.
For example use =A2# as list source.
XelPlus.com 18
Performance Testing
Array Referencing versus Standard Referencing
More info on Calculation speed and VBA code is provided by Excel MVP Charles Williams here.
Advanced
The ONE Theory you NEED to Use
FILTER Like a Pro
Expert
Advanced to Expert: How Arrays
Really Work
XelPlus.com 20
Why Boolean Logic is Important
Understanding this enables you to:
• Take advantage of Excel’s FILTER & other functions
• Easily handle complex data analysis
• For example filter results based on a more complicated AND, OR conditions
• Understand why this formula =FILTER(A5:A10,B5:B10<>0) is the same as
this one =FILTER(A5:A10,B5:B10)
FILTER function, filters values which return TRUE in the include argument:
=FILTER(A5:A10,B5:B10<>0)
Highlight each argument and
press F9 (To reverse – press
Is translated to Control + Z or Escape)
Guess what?
You can also write the formula this way:
FILTER(A5:A10,B5:B10)
XelPlus.com 21
Excel’s Boolean Logic (TRUE, FALSE) Explained
TRUE in Excel takes different forms
TRUE is:
Any non-zero number (positive & negative values)
FALSE is:
Zero or empty cell
XelPlus.com 22
FILTER Like a PRO
AND logical test (*) OR logical test (+)
=FILTER(A7:C22,(ISNUMBER(C7:C22))*(C7:C22<>0))
=FILTER(B5:C20,(C5:C20>100000)+(C5:C20<30000),"No Data")
XelPlus.com 23
Excel Array Syntax
Rules for inputting array constants in new DA Excel:
• Wrap array constants in curly brackets { }
• Comma “,” represents column split and Semicolon “;” is for rows
Example: ={1,2}
Example: ={1;2}
Example: ={1,2;3,4;5,6}
XelPlus.com 24
Debugging Formula Trick
Why Debug?
• Understand why your formula returns wrong values
• Write complex formulas & view results one step at a time
Highlight
B14:B19>40000 in
the formula bar and
press F9.
XelPlus.com 25
Course Road Map
Basic Dynamic Arrays & Excel’s New Calculation
Engine (Hash / Spilled referencing)
Advanced
The ONE Theory you NEED to Use
FILTER Like a Pro
Expert
Advanced to Expert: How Arrays
Really Work
XelPlus.com 26
Lifting Array Behavior
If a formula expects a scalar (one value) but is given an array,
the function lifts the multiple values to provide an output with
multiple results.
If more than one value is provided, the MONTH function will return many
values.
Press F9 to debug
XelPlus.com 27
Pairwise Lifting Array Behavior
When multiple arrays of the same size are provided instead of
two scalars, they are lifted in pairs.
Press F9 to debug
In Legacy Excel they couldn’t spill on the grid – There we visible in the
formula bar but Excel wasn’t able to show all these values in one cell. It
only showed one result.
XelPlus.com 28
Broadcasting Excel Array Behavior
When we have arrays of different sizes, we need to expand the
smaller ones to be the same size as the big one so we can do
pairwise lifting.
XelPlus.com 29
Implicit Intersection
This is the answer to why some Legacy Formulas needed
Control Shift Enter – if you didn’t use CSE, you’d get a result
based on Implicit Intersection.
Legacy Excel
If the formula is written in B2, the month formula returns the month
of the date in A2.
If it is written in B3, it will return A3.
This is implicit intersection.
If it is written in B4, it will return an error as there are no values in
front of the formula.
Formula is wrapped
inside the SINGLE
function to ensure it
doesn’t
unintentionally
spill.
XelPlus.com 30
Are CSE Formulas No Longer Needed?
Short answer: No, they are NO longer needed.
What Microsoft
Suggests
In some cases you can use CSE to avoid (too much) spillage
XelPlus.com 31
Course Road Map
Basic Dynamic Arrays & Excel’s New Calculation
Engine (Hash / Spilled referencing)
Advanced
The ONE Theory you NEED to Use
FILTER Like a Pro
Expert
Advanced to Expert: How Arrays
Really Work
XelPlus.com 32
THANK YOU!
Please take a few seconds to
leave a review for the course.
Your support is very much
appreciated.
XelPlus.com 33
More Learning…