Excel functions / New in Excel
New Excel functions: dynamic arrays, LAMBDA and more
In Excel 2021, Excel 2024 and Microsoft 365, a formula can return a whole list that fills the cells around it. On that idea sit 35 newer functions: XLOOKUP, FILTER and SORT, the stacking and reshaping functions, TEXTSPLIT and the regular expression functions, LET and LAMBDA, and GROUPBY and PIVOTBY, which build a PivotTable as a formula. Each one below links to a beginner's guide with worked examples, the mistakes and errors to watch for, the older way to do the same job, and an exercise to practice it.
How dynamic arrays work
Type the formula in one cell. Its results spill into the cells below and beside it, and the area resizes when the data changes. Only the first cell holds the formula; the others show its results and cannot be edited on their own.
One formula, a whole list: each region once, A to Z
A B C 1 Region 2 North North 3 South South 4 North West 5 West 6 South In C2:
=SORT(UNIQUE(A2:A6))→ North; South; WestThe formula is only in C2. C3 and C4 show the rest of its result: it spills.
The # after a cell: the whole spilled list
A B C D E 1 Region Regions 2 North North 3 3 South South 4 North West 5 West 6 South In E2:
=COUNTA(C2#)→ 3C2# means "everything C2 spills". When the list grows or shrinks, the count follows.
When something is in the way, the formula shows #SPILL!. When a list comes out empty, such as a FILTER that matches nothing, it shows #CALC!. And in a version of Excel that does not have the function, it shows #NAME?.
Which Excel has which
- Excel 2021 and later: XLOOKUP, XMATCH, FILTER, SORT, SORTBY, UNIQUE, SEQUENCE, LET.
- Excel 2024 and Microsoft 365: VSTACK, HSTACK, TAKE, DROP, CHOOSECOLS, CHOOSEROWS, TOCOL, TOROW, WRAPROWS, WRAPCOLS, EXPAND, TEXTSPLIT, TEXTBEFORE, TEXTAFTER.
- Microsoft 365: GROUPBY, PIVOTBY, PERCENTOF, REGEXTEST, REGEXEXTRACT, REGEXREPLACE, LAMBDA, MAP, REDUCE, SCAN, BYROW, BYCOL, MAKEARRAY.
A function listed under Excel 2021 is also in Excel 2024 and Microsoft 365. Functions under Microsoft 365 are in Excel for Microsoft 365; a version you buy once may not have them.
Look things up
XLOOKUP and XMATCH replace VLOOKUP, HLOOKUP and MATCH. They match exactly unless you ask otherwise, look in either direction, and can search from the bottom up.
- XLOOKUP (Excel 2021 and later): Searches a range and returns the matching item from another range. The modern replacement for VLOOKUP.
=XLOOKUP("P-103", A2:A5, C2:C5)→ 8.9 - XMATCH (Excel 2021 and later): The position of a value in a list, with exact match by default.
=XMATCH("Chloe", A2:A6)→ 3
Filter, sort and list
The first dynamic array functions. Each returns a whole list from one formula, which spills into the cells below and updates when the data changes.
- FILTER (Excel 2021 and later): Keeps only the rows that meet a condition. The result spills.
=FILTER(A2:A5, B2:B5="North")→ Ana; Chloe - SORT (Excel 2021 and later): Sorts a range. The result spills.
=SORT(A2:A5)→ Ana; Ben; Chloe; Dev - SORTBY (Excel 2021 and later): Sorts a range by the values in another range.
=SORTBY(A2:A5, C2:C5, -1)→ Ana; Chloe; Ben; Dev - UNIQUE (Excel 2021 and later): Removes duplicates from a list. The result spills.
=UNIQUE(A2:A6)→ North; South; West - SEQUENCE (Excel 2021 and later): Generates a list of sequential numbers that spills into neighboring cells.
=SEQUENCE(5)→ 1; 2; 3; 4; 5
Summarize like a PivotTable
GROUPBY and PIVOTBY build the summary a PivotTable would, as a formula: totals by group, a cross-tab with totals, and shares of the total with PERCENTOF. Unlike a PivotTable, they never need refreshing.
- GROUPBY (Microsoft 365): Groups rows by one or more fields and aggregates values for each group, with a total row: a pivot by formula that updates live. Spills.
=GROUPBY(A2:A6, C2:C6, SUM)→ North, 2400; South, 800; West, 400; Total, 3600 - PIVOTBY (Microsoft 365): Summarizes values by row fields down the side and a column field across the top, with totals: a PivotTable by formula that updates live. Spills.
=PIVOTBY(A2:A6, B2:B6, C2:C6, SUM)→ , Ana, Ben, Chloe, Total; North, 1500, , 900, 2400; South, , 800, , 800; West, 400, , , 400; Total, 1900, 800, 900, 3600 - PERCENTOF (Microsoft 365): What share one set of values is of the whole: SUM(data_subset) ÷ SUM(data_all). Also works as the function in GROUPBY and PIVOTBY.
=PERCENTOF(SUMIF(A2:A6, "North", C2:C6), C2:C6)→ 67%
Reshape ranges
Stack ranges together, keep or drop rows and columns, and fold a list into a grid or a grid into a list. They are most useful wrapped around other formulas, to shape a result before it spills.
- VSTACK (Excel 2024 and Microsoft 365): Stacks arrays on top of each other into one taller array.
=VSTACK(A2:A3, C2:C3)→ Ana; Ben; Dev; Eve - HSTACK (Excel 2024 and Microsoft 365): Places arrays side by side into one wider array.
=HSTACK(C1:C3, A1:A3)→ Sales, Region; 1200, North; 800, South - TAKE (Excel 2024 and Microsoft 365): Keeps the first or last rows or columns of an array.
=TAKE(A2:C5, 2)→ Ana, North, 1200; Ben, South, 800 - DROP (Excel 2024 and Microsoft 365): Removes the first or last rows or columns of an array.
=DROP(A1:A4, 1)→ Pen; Stapler; Folder - CHOOSECOLS (Excel 2024 and Microsoft 365): Returns the columns you name from an array, in the order you name them.
=CHOOSECOLS(A1:C3, 2, 3)→ Rep, Sales; Ana, 1200; Ben, 800 - CHOOSEROWS (Excel 2024 and Microsoft 365): Returns the rows you name from an array, in the order you name them.
=CHOOSEROWS(A2:A7, 1, -1)→ Pen; Ruler - TOCOL (Excel 2024 and Microsoft 365): Turns an array into a single column.
=TOCOL(A2:C3)→ 10; 20; 30; 40; 50; 60 - TOROW (Excel 2024 and Microsoft 365): Turns an array into a single row.
=TOROW(A2:A4)→ Pen, Stapler, Folder - WRAPROWS (Excel 2024 and Microsoft 365): Wraps a row or column of values into rows of a set length.
=WRAPROWS(A2:A7, 3)→ Pen, Stapler, Folder; Tape, Glue, Ruler - WRAPCOLS (Excel 2024 and Microsoft 365): Wraps a row or column of values into columns of a set length.
=WRAPCOLS(A2:A7, 2)→ Pen, Folder, Glue; Stapler, Tape, Ruler - EXPAND (Excel 2024 and Microsoft 365): Grows an array to a set number of rows and columns, filling the new cells.
=EXPAND(A2:A3, 2, 3, "-")→ Pen, -, -; Tape, -, -
Split and match text
TEXTSPLIT, TEXTBEFORE and TEXTAFTER do in one step what used to take LEFT, MID and FIND together. The REGEX functions test, pull out and replace text by pattern: a run of digits, an email address, a code in a set format.
- TEXTSPLIT (Excel 2024 and Microsoft 365): Splits text into separate cells at a delimiter. The result spills.
=TEXTSPLIT(A2, ",")→ Ana, Lopez, Madrid - TEXTBEFORE (Excel 2024 and Microsoft 365): The text that comes before a delimiter.
=TEXTBEFORE(A2, "@")→ ana.lopez - TEXTAFTER (Excel 2024 and Microsoft 365): The text that comes after a delimiter.
=TEXTAFTER(A2, "@")→ example.com - REGEXTEST (Microsoft 365): TRUE if any part of the text matches a regular expression.
=REGEXTEST(A2, "^\d{5}quot;)→ TRUE - REGEXEXTRACT (Microsoft 365): The part of the text that matches a regular expression: the first match, all of them, or its groups.
=REGEXEXTRACT(A2, "[0-9]+")→ 4471 - REGEXREPLACE (Microsoft 365): Replaces the parts of the text that match a regular expression.
=REGEXREPLACE(A2, "\D", "")→ 5551234567
Name things and write your own functions
LET names the parts of a long formula. LAMBDA turns a formula into a function, and MAP, REDUCE, SCAN, BYROW, BYCOL and MAKEARRAY run it over a range, row by row or value by value, in place of a helper column.
- LET (Excel 2021 and later): Names intermediate results so a formula is easier to read.
=LET(total, A2*B2, total - total*C2)→ 108 - LAMBDA (Microsoft 365): Makes a function of your own: names for its inputs, then the calculation.
=LAMBDA(net, rate, net*(1+rate))(A2, B2)→ 240 - MAP (Microsoft 365): Runs a function on each value of an array and returns the results in the same shape.
=MAP(A2:A4, LAMBDA(p, CEILING.MATH(p*1.2, 0.05)))→ 1.45; 10.70; 2.90 - REDUCE (Microsoft 365): Boils an array down to one result by running a function on a running value and each item in turn.
=REDUCE(0, A2:A5, LAMBDA(total, x, IF(ISEVEN(x), total+x, total)))→ 18 - SCAN (Microsoft 365): Like REDUCE, but returns every step: a running total, a running maximum and the like.
=SCAN(0, A2:A4, LAMBDA(total, x, total+x))→ 100; 250; 340 - BYROW (Microsoft 365): Runs a function on each row of an array and returns one result per row.
=BYROW(A2:C3, LAMBDA(row, SUM(row)))→ 60; 150 - BYCOL (Microsoft 365): Runs a function on each column of an array and returns one result per column.
=BYCOL(A2:C3, LAMBDA(col, SUM(col)))→ 50, 70, 90 - MAKEARRAY (Microsoft 365): Builds an array of a set size, working out each cell from its row and column number.
=MAKEARRAY(3, 3, LAMBDA(r, c, r*c))→ 1, 2, 3; 2, 4, 6; 3, 6, 9
Also new, without a live example here
Two more functions in current Excel that this site's spreadsheet does not calculate, so there is nothing to try here. In Excel they work as described.
TRIMRANGE (Microsoft 365)
A range with the empty rows and columns around its edges taken off.
TRIMRANGE(range, [trim_rows], [trim_cols])
range: The range to trim, such as a whole column.trim_rows: Which empty rows to take off: 0 none, 1 those at the start, 2 those at the end, 3 both (the default).trim_cols: Which empty columns to take off, with the same numbers.
It lets a formula point at more rows than the data has, such as A2:A10000, without carrying thousands of empty cells into the result: a list of names that grows, passed to UNIQUE or SORT, stops at the last name.
IMAGE (Microsoft 365)
A picture from a web address, shown inside a cell.
IMAGE(source, [alt_text], [sizing], [height], [width])
source: The address of the picture, starting with https.alt_text: A description of the picture, for screen readers.sizing: 0 fits the picture in the cell and keeps its shape (the default), 1 fills the cell, 2 keeps the picture's own size, 3 uses the height and width given.height, width: The size in pixels, with sizing 3.
The picture belongs to the cell: it moves and sorts with the row, which a picture placed over the sheet does not.
Practice them
Every function page above ends with an exercise in a live sheet that checks your answer. For more, these lessons use the newer functions step by step, or try the Excel practice exercises by skill.
- XLOOKUP
- Splitting text at a character
- Split and clean text: TEXTSPLIT and REGEX
- GROUPBY and PIVOTBY: PivotTables as formulas
- Bar charts for long names
- Finding duplicates
- Spilling arrays: UNIQUE and SORT
- FILTER: rows that match
- SORTBY, SEQUENCE and LET
- Reshape a list: TAKE, DROP and CHOOSECOLS
- Combine lists: VSTACK and HSTACK
- Your own calculations: LAMBDA, BYROW and MAP
- Running results: SCAN and REDUCE
- Challenge: stock room reorder list
Common questions
What are dynamic arrays in Excel?
Formulas that return more than one value. Typed in one cell, the results spill into the cells below and beside it, and the area grows or shrinks as the data changes. FILTER, SORT, UNIQUE and SEQUENCE were the first; the newer functions on this page build on them.
Why does a new function show #NAME? on my computer?
Your version of Excel does not have it. Each function on this page says which versions do. A file made in Microsoft 365 still opens in older Excel, but the formulas with newer functions show #NAME? there, so check who will open the file before using them.
What does the @ in a formula mean?
It asks for a single value where a range could return many: =@A2:A10 takes the value on the formula's own row. Excel adds it by itself when a file from an older version is opened, so that old formulas keep returning one value instead of spilling.
What does #SPILL! mean?
A formula that returns several values has no room to put them: one of the cells it needs is not empty. Click the formula and Excel outlines the area it wants; clear whatever is inside it.
Can I use these functions in Google Sheets?
Many have a version there with the same name, such as FILTER, SORT, UNIQUE, SEQUENCE, XLOOKUP and LAMBDA, but not all do, and some behave a little differently. This page describes Excel.