Skip to content

MAP

Runs a LAMBDA on every value of one or more arrays and returns the results in an array of the same shape.

Syntax

=MAP(, [array2], …, )

LAMBDA and LET

Excel for Microsoft 365, Excel 2024 and later, and Excel for the web. Not available in Excel 2021 or earlier.

Try it

Edit the formula in E2 or change the inputs. The sheet recalculates as you type.

E2
A
B
C
D
E
F
1
Store
Sales
Target
2
Dock St
120
100
On target
3
Mill Rd
90
100
Below
4
High St
150
120
On target
5
Park Ave
60
80
Below
6
Quay Side
100
100
On target
7

E2 =MAP(B2:B6,LAMBDA(v,IF(v>=100,"On target","Below"))) returns On target; Below; On target; Below; On target

How MAP works

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.

Arguments

array1
The first range or array. The LAMBDA receives its values one at a time.
array2, …optional
More arrays of the same size. Each one needs its own parameter in the LAMBDA, and the values are passed in matching positions.
lambda
A LAMBDA with one parameter per array, such as LAMBDA(x,x*2). It must return a single value for each item. It is always the last argument.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Label each store as on target or below

E2 =MAP(B2:B6,LAMBDA(v,IF(v>=100,"On target","Below")))

Result: On target; Below; On target; Below; On target

The LAMBDA runs five times, once per sales figure. Quay Side hits exactly 100, which counts as on target.

E2
A
B
C
D
E
F
1
Store
Sales
Target
2
Dock St
120
100
On target
3
Mill Rd
90
100
Below
4
High St
150
120
On target
5
Park Ave
60
80
Below
6
Quay Side
100
100
On target
7

E2 =MAP(B2:B6,LAMBDA(v,IF(v>=100,"On target","Below"))) returns On target; Below; On target; Below; On target

Example 2

Two arrays: the variance to target

E2 =MAP(B2:B6,C2:C6,LAMBDA(s,t,s-t))

Result: 20; -10; 30; -20; 0

The LAMBDA has two parameters. Each call gets one sales figure and the target from the same row.

E2
A
B
C
D
E
F
1
Store
Sales
Target
2
Dock St
120
100
20
3
Mill Rd
90
100
-10
4
High St
150
120
30
5
Park Ave
60
80
-20
6
Quay Side
100
100
0
7

E2 =MAP(B2:B6,C2:C6,LAMBDA(s,t,s-t)) returns 20; -10; 30; -20; 0

Example 3

Build a short code from each name

E2 =MAP(A2:A6,LAMBDA(n,UPPER(LEFT(n,3))))

Result: DOC; MIL; HIG; PAR; QUA

LEFT takes the first three letters and UPPER capitalises them, for each name in turn.

E2
A
B
C
D
E
F
1
Store
Sales
Target
2
Dock St
120
100
DOC
3
Mill Rd
90
100
MIL
4
High St
150
120
HIG
5
Park Ave
60
80
PAR
6
Quay Side
100
100
QUA
7

E2 =MAP(A2:A6,LAMBDA(n,UPPER(LEFT(n,3)))) returns DOC; MIL; HIG; PAR; QUA

Example 4

Add up the digits of each number

C2 =MAP(A2:A4,LAMBDA(x,SUM(--MID(x,SEQUENCE(LEN(x)),1))))

Result: 15; 8; 18

For 4821, SEQUENCE(4) gives 1 to 4, MID splits out each digit, and SUM adds 4+8+2+1 = 15. This needs a fresh array for each number, which is what MAP provides.

C2
A
B
C
D
E
F
1
Code
2
4821
15
3
3050
8
4
99
18
5

C2 =MAP(A2:A4,LAMBDA(x,SUM(--MID(x,SEQUENCE(LEN(x)),1)))) returns 15; 8; 18

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In D2, return the line total (quantity times unit price) for every row. Use MAP with both columns.

Answer in D2.

D2
A
B
C
D
E
F
G
H
1
Qty
Unit price
2
12
8
3
40
3
4
6
25
5
150
2
6
75
12
7
20
9
8

Common mistakes

  • If the LAMBDA returns more than one value for an item, such as a whole row, MAP returns #CALC!. Each call must return a single value.
  • The number of LAMBDA parameters must match the number of arrays. Two arrays and a one-parameter LAMBDA make the formula invalid.
  • Before reaching for MAP, check that a plain array formula won't do. =B2:B6*2 is simpler and quicker than =MAP(B2:B6,LAMBDA(x,x*2)).
  • Arrays of different sizes do not line up. Give MAP arrays of the same height and width.
  • #SPILL! means the cells the result needs are not empty.

Questions people ask

What does MAP do in Excel?

It runs a LAMBDA function on every item of an array and returns the results as an array of the same size. It is how you apply a custom calculation to each cell of a range with one formula.

When should I use MAP instead of a normal array formula?

When each item needs a calculation that is more than a single array operation, such as building an array inside the calculation, or when you want a named, reusable rule. For simple arithmetic, a plain array formula is easier.

Why does MAP return #CALC!?

The LAMBDA returned more than one value for an item, and MAP can only place one value in each cell of the result. Make the LAMBDA return a single value, for example by wrapping the calculation in SUM or TEXTJOIN.

Can MAP use more than one array?

Yes. List the arrays first and the LAMBDA last, with one parameter for each array: `=MAP(B2:B6,C2:C6,LAMBDA(s,t,s-t))`.

Does MAP work in Excel 2021?

No. It is available in Microsoft 365, Excel 2024 and later, and Excel for the web. Earlier versions return `#NAME?`.

Learn MAP in a real sheet.

MAP is taught in Dates and financial modelling, lesson 22: Reusable calculations with LAMBDA. Each lesson is a short, graded exercise like the one above.