MAP

Short answer

Apply logic to every cell in a range

MAP(array1, [array2, ...], lambda)
Excel version
2024+
Also searched as
apply formula to every cell, commission calculation excel, and or in array formula, per row calculation spill, map lambda excel

What it returns

MAP walks through one or more arrays cell by cell, hands the values at each position to a LAMBDA, and returns an array of the same shape holding the results. Give it a column of 40 sales figures and you get a column of 40 answers.

With two or more arrays, the LAMBDA gets one value from each, matched by position. The first sales figure goes in with the first quota, the second with the second, and so on. The arrays should be the same size.

Plain array math already does this for simple cases. =Reps[Sales]*0.05 spills a commission per rep without MAP. MAP is for the logic that does not spill on its own, and that is mostly AND, OR and anything that aggregates. AND(Reps[Sales]>=Reps[Quota], Reps[Months]>=6) returns a single TRUE or FALSE for the whole column, not one per rep. Inside MAP, AND sees one rep at a time and behaves.

Arguments that matter

ArgumentRequiredWhat it does
array1YesThe first range or array to walk through. Sets the shape of the result.
array2, …NoFurther arrays, matched cell by cell with array1. Keep them the same size.
lambdaYesThe last argument. A LAMBDA with one parameter per array, in the same order. Must return one value.

The parameter count is the argument that trips people. Three arrays need a LAMBDA with three parameters. One too many or one too few and MAP returns #VALUE!.

Order matters too. The first parameter receives array1, the second array2. Swap the arrays and the names in the LAMBDA now describe the wrong data, with no error to tell you.

In a financial model

MAP belongs where a model has per-row rules with more than one condition: commission plans, bonus eligibility, tax brackets with exemptions, covenant tests that depend on two ratios at once.

The old answer was a filled-down column of nested IFs. It works, but it is one formula per row, each one a chance for an override, and the nesting gets deep fast. The play on three levels of nesting is the limit is aimed at exactly that column.

MAP keeps the rule in one place and spills the result. Add a rep to the Table and the commission appears. Change the accelerator rate on the inputs tab and every rep updates.

For a rule used in several places, name the LAMBDA and pass the name: =MAP(Reps[Sales], Reps[Quota], Reps[Months], Commission). The rule now has one definition across the workbook.

Worked example

A sales roster on tab Reps, a Table with columns Rep, Sales, Quota, Months (tenure in months). Inputs as defined names on the inputs tab: BaseRate 5%, AccelRate 8%, MinTenure 6.

The rule: a rep at or above quota with at least six months’ tenure earns the accelerator on all sales. Everyone else earns the base rate.

=MAP(Reps[Sales], Reps[Quota], Reps[Months],
  LAMBDA(sales, quota, tenure,
    IF(AND(sales >= quota, tenure >= MinTenure), sales * AccelRate, sales * BaseRate)))

Entered once beside the Table, it spills one commission per rep.

RepSalesQuotaMonthsCommission
Rep A520,000500,0001441,600
Rep B610,000500,000430,500
Rep C380,000450,0002219,000

Rep B beat quota but is short on tenure, so AND fails and the base rate applies. That is the case a plain array formula gets wrong: written without MAP, AND would test every rep at once and return one answer for the whole column.

Old way vs new way

Filled down a helper column, one copy per rep:

=IF(B2>=C2, IF(D2>=6, B2*0.08, B2*0.05), B2*0.05)

One formula, spilled:

=MAP(Reps[Sales], Reps[Quota], Reps[Months], LAMBDA(sales, quota, tenure, IF(AND(sales>=quota, tenure>=MinTenure), sales*AccelRate, sales*BaseRate)))

The old version repeats the base-rate branch, hard-codes both rates and the tenure rule, and needs copying for every new hire. The new one reads in order and pulls every number from the inputs tab.

Where it breaks

MAP returns #VALUE!. The LAMBDA has the wrong number of parameters for the arrays passed. Three arrays, three parameters. Fix: count both and match them, keeping the parameter order the same as the array order.

MAP returns #CALC!. The LAMBDA returns more than one value for a cell, such as a lookup that returns a whole row. Fix: make the LAMBDA return a single value. If you want a whole row per input, MAP is the wrong tool.

Every rep gets the same rate. The formula was written without MAP, and AND or OR collapsed the whole column to one TRUE or FALSE. Fix: move the logic inside MAP, or replace AND with multiplication of the conditions, (Reps[Sales]>=Reps[Quota])*(Reps[Months]>=MinTenure), which does spill.

The numbers are plausible but wrong. The arrays are in a different order from the parameters, so quota is receiving tenure. Nothing errors. Fix: line the arrays and parameter names up on separate lines with Alt+Enter, and test one row against a hand calculation.

#SPILL! next to the Table. MAP was entered inside the Table, or the cells below the anchor are not empty. Fix: enter it in a plain range beside the Table and clear the spill area.

Every cell shows #NAME?. MAP needs Excel 2024 or Microsoft 365. Fix: for files that go to Excel 2021 or earlier, keep a filled-down column.

Related functions

  • LAMBDA. MAP’s last argument. Name the commission rule once and pass the name.
  • BYROW. Hands the LAMBDA a whole row instead of one cell. Use it when the answer depends on many columns of a grid, such as a row total.
  • XLOOKUP. For a tiered rate with a single condition, XLOOKUP(Reps[Sales], Tiers[Floor], Tiers[Rate], , -1) spills without MAP. Reach for MAP when a second condition joins in.
  • SUMPRODUCT. For a single total across conditions, not one answer per row.
  • LET. Use it inside the LAMBDA when the per-cell logic has steps worth naming.
  • MAKEARRAY. Builds a grid from row and column positions instead of from existing ranges.
  • Read no constants inside formulas before typing a rate into the LAMBDA.

All functions