Map array to custom function
=MAP(array1, [array2], ..., lambda)
| Parameter | Description |
|---|---|
array1 |
The array to be mapped. |
array2 |
[optional] Additional arrays required by the LAMBDA. |
lambda |
The custom LAMBDA function to apply. |
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
=MAP({1,2,3},LAMBDA(a,a+1)) // returns {2,3,4}
In the worksheet shown above, MAP is used to remove non-numeric values from the array provided (B5:D16). The formula in F5 is:
=MAP(B5:D16,LAMBDA(a,IF(ISNUMBER(a),+a,"")))
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
=MAP({1,2,3},{1,2,3},LAMBDA(a,b,a+b)) // returns {2,4,6}
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
=array+1
=MAP(array,LAMBDA(a,a+1))
=MAP(rng1,rng2,rng3,LAMBDA(a,b,c,MAX(a,b,c)))