MAP applies a calculation to every item of an array and gives back an array of the same shape. You write the calculation once as a LAMBDA, and MAP runs it for each value.
The arguments
Give MAP one or more arrays, and then the LAMBDA as the last argument. The LAMBDA needs one parameter for each array. With one array, =MAP(B2:B6,LAMBDA(v,IF(v>=100,"On target","Below"))) calls the LAMBDA five times, once for each sales figure, with v holding that figure. With two arrays, =MAP(B2:B6,C2:C6,LAMBDA(s,t,s-t)) passes the matching value of each array every time: s from the first, t from the second.
The result has the same shape as the input arrays and spills. If the inputs are a 5-row column, you get a 5-row column back.
Why not just use an array formula?
Most of the time you can, and you should. =B2:B6-C2:C6 already works on arrays and is simpler than a MAP. MAP is for the cases where a plain array formula doesn't do what you want:
- A calculation that needs several steps per item. The digit sum of a number, a custom label, a nested IF with a lookup in it.
- Functions that don't map over arrays on their own. Some functions work on a whole array and return one answer. MAP lets you call them once per item.
- A reusable rule. The LAMBDA can be a named function from the Name Manager, so the same logic runs in several places.
For example, adding up the digits of each number needs an array inside the calculation for each item:
=MAP(A2:A4,LAMBDA(x,SUM(--MID(x,SEQUENCE(LEN(x)),1))))
The SEQUENCE inside the LAMBDA is a different array for each number, which a normal array formula can't express.
The LAMBDA must return one value
Whatever the LAMBDA returns for an item must be a single value: a number, text, a logical or an error. If it returns a range or a list, MAP returns #CALC!, because it can't fit a list into one cell of the result. If you need to return a row for each item, use a different function such as BYROW, or build the result with VSTACK.
Rules and limits
The arrays must be the same size. The LAMBDA's parameter count must match the number of arrays, or Excel refuses the formula.
See LAMBDA for how to write and save the function. REDUCE, SCAN, BYROW and BYCOL are the other helpers. The output spills, so #SPILL! means the cells it needs aren't empty.
MAP needs Microsoft 365, Excel 2024 or later, or Excel for the web.