ID EN
#Dynamic array

MAP

Excel Functions

Map array to custom function

Syntax

EXCEL
=MAP(array1, [array2], ..., lambda)

Arguments

Parameter Description
array1 The array to be mapped.
array2 [optional] Additional arrays required by the LAMBDA.
lambda The custom LAMBDA function to apply.

Return Value

Array of results

Details

The MAP function "maps" a custom LAMBDA function to each value in a supplied array. The LAMBDA is applied to each value, and the result from MAP is an array of results with the same dimensions as the original array. The MAP function is useful when you want to process each item in an array individually but as an array operation that yields an array result. MAP is also useful when the formula logic is complex and would be best managed in a single location. Using a named LAMBDA function with MAP is possible to reuse the same code elsewhere. The MAP function takes two required arguments: array1 and lambda. Array1 is the array that should be mapped. Lambda is the custom lambda function that should be run on each item in array1. Additional arguments can be added in the form of array2, array3, et

Examples

Examples

The MAP function maps each value in an array to a custom LAMBDA function. For example, the formula below maps a LAMBDA function that simply adds 1 to

EXCEL
=MAP({1,2,3},LAMBDA(a,a+1)) // returns {2,3,4}
Remove non-numeric values

In the worksheet shown above, MAP is used to remove non-numeric values from the array provided (B5:D16). The formula in F5 is:

EXCEL
=MAP(B5:D16,LAMBDA(a,IF(ISNUMBER(a),+a,"")))
Additional arrays

MAP can accept additional arrays that can be used by the LAMBDA during calculation. The formula below adds each item in array1 to the corresponding it

EXCEL
=MAP({1,2,3},{1,2,3},LAMBDA(a,b,a+b)) // returns {2,4,6}
When to use MAP

The dynamic array engine in Excel can handle many array operations natively without a function like MAP. For example, the formulas below both return t

EXCEL
=array+1
=MAP(array,LAMBDA(a,a+1))
When to use MAP
EXCEL
=MAP(rng1,rng2,rng3,LAMBDA(a,b,c,MAX(a,b,c)))

See Also

LAMBDA LET MAP SCAN REDUCE MAKEARRAY BYCOL BYROW