Table of Contents
Excel's MAP function applies a LAMBDA calculation to each corresponding value in one or more arrays and returns the results as a spilled array. It is useful when you want one formula to define the same rule for an entire list.
Microsoft lists MAP for Excel for Microsoft 365 and Excel 2024, including their Mac versions. Do not assume that every Excel version with dynamic arrays also includes MAP; Excel 2021 is not listed on the MAP support page.
How the formula works
=MAP(array1, [array2], ..., LAMBDA(value1, [value2], ..., calculation))
The square brackets indicate optional arguments; do not type them. Give the LAMBDA one parameter for each input array. For row-by-row examples, use equally sized ranges and put the formula in a blank output column with enough room below it. These examples use commas; your regional Excel settings may require semicolons.
1. Flag inventory against reorder points
Suppose B2:B11 contains quantities and C2:C11 contains reorder points. Enter this in D2:
=MAP(B2:B11, C2:C11, LAMBDA(qty, reorder_point, IF(qty=0, "OUT", IF(qty<=reorder_point, "LOW", "OK"))))
The formula compares B2 with C2, then B3 with C3, and so on. A quantity of zero returns OUT; a positive quantity at or below its reorder point returns LOW; a higher quantity returns OK. This rule assumes valid numeric quantities and thresholds.
2. Keep the stock rule in one formula
A conventional formula such as the following works when filled down:
=IF(B2=0, "OUT", IF(B2<=C2, "LOW", "OK"))
MAP offers a different maintenance approach: edit the top-left formula once to update the whole spilled result. Individual output cells are not independent formulas that you can edit. This reduces inconsistent formula edits, but it does not prevent incorrect source data or an incorrect rule in the main formula. It is not a universal performance improvement.
3. Reuse the rule as a named LAMBDA
In desktop Excel, open Formulas > Name Manager > New. Use CheckStock as the name, set workbook scope if you want to reuse it throughout the workbook, and enter this in Refers to:
=LAMBDA(qty, reorder, IF(qty=0, "OUT", IF(qty<=reorder, "LOW", "OK")))
Test it with =CheckStock(0,5), which should return OUT, and =CheckStock(6,5), which should return OK. Then use:
=MAP(B2:B100, C2:C100, CheckStock)
Changing CheckStock updates formulas that use the name, so review those dependent calculations before changing the rule. See our LAMBDA function guide for more on named functions.
4. Calculate ordinary and tiered discounts
If B2:B5 contains prices and C2:C5 contains discounts entered as percentages, use:
=MAP(B2:B5, C2:C5, LAMBDA(price, discount, price*(1-discount)))
A price of 100 with a discount of 10% returns 90. Enter 10% or 0.1 for that discount, not the number 10.
For an example rule that takes 15% off prices above 100 and 5% off other prices:
=MAP(A2:A50, LAMBDA(price, IF(price>100, price*0.85, price*0.95)))
A price exactly equal to 100 receives the 5% discount. Check boundary values whenever a pricing rule uses > or <=.
5. Clean a list of product names
=MAP(A2:A1000, LAMBDA(item, PROPER(TRIM(item))))
This trims ordinary extra spaces and applies title case to each value. Review acronyms and brand names because PROPER may change capitalization you wanted to keep. TRIM does not remove every kind of whitespace, such as nonbreaking spaces.
Troubleshoot and maintain the result
- #SPILL!: check for occupied or merged cells in the output area. Put the formula outside an Excel table.
- #VALUE! with Incorrect Parameters: check that the LAMBDA parameter count matches the number of arrays.
- #NAME?: check the function name, named LAMBDA, and whether your Excel version supports MAP.
- Missing new rows: a fixed reference such as A2:A1000 does not include row 1001. Update the range or use structured references to a source table, with the spilling formula outside that table.
Microsoft's spilled-array guidance explains output restrictions. Our Excel error guide covers other common formula problems.
Reader Comments 0
Sign in with email or Google to join the discussion.