Table of Contents
Excel's MAP function applies a LAMBDA calculation to each value in one or more arrays and returns the results as a dynamic array. It is useful when each item needs the same custom logic, especially when that logic combines multiple inputs.
Microsoft lists MAP for Excel for Microsoft 365 and Excel 2024, including their Mac editions. Do not assume it is available in Excel 2021. Check the MAP function reference for your edition.
How does the MAP function work?
The MAP function takes a range of data and applies a custom calculation to the entire data set at once. It uses the following syntax:
=MAP(array, lambda)
Let's analyze the parameters:
- array : This is the range of cells you want to process. It can be one column, multiple columns, or even an entire table. MAP will iterate through each value in this range.
- lambda : This is where you define the calculation. LAMBDA names each input value and defines the result to return. Supply one parameter for each input array, followed by the calculation.
When you run MAP, it applies your lambda function to every cell in the array and returns a new set of results. The output matches the size and shape of the input, so if you enter 10 rows, you get 10 results.
Start with a simple task to see how MAP works
Let's say you have a list of product prices and need to add a 10% markup to each price. The traditional way would be to write a formula like =B2*1.1 and drag it down. However, MAP handles this differently.
Instead of writing individual formulas, you create a MAP function that processes the entire price column:
=MAP(B2:B11, LAMBDA(price, price*1.1))
Here's what happens: MAP takes each value in B2:B11 (your price range) and feeds it into the LAMBDA function. LAMBDA assigns each value to the variable "price", multiplies it by 1.1, and returns the result. All in one step.
Add logic to MAP with IF statements
MAP is not limited to simple calculations. You can add Excel conditional functions inside the LAMBDA function to handle different situations based on the data.
Let's say you want to apply different markups depending on price. Products that are $100 or more get a 10% markup, while products under that get a 15% markup. You might write something like this:
=MAP(B2:B11, LAMBDA(price, IF(price>=100, price*1.1, price*1.15)))
The IF statement checks each price as MAP processes. If the price is $100 or more, it will multiply by 1.1. Otherwise, it will multiply by 1.15.
MAP handles multiple columns and messy text data
MAP is not limited to single column operations. You can feed multiple arrays into the function and process them together in one function.
Let's say you want to calculate total sales by multiplying price and quantity. Instead of creating a separate formula column, use MAP to handle both:
=MAP(B2:B11, C2:C11, LAMBDA(price, qty, price*qty))
MAP takes two arrays - B2:B11 (price) and C2:C11 (quantity) - and processes them row by row. The LAMBDA function takes both values, multiplies them, and returns the result.
You can also use the MAP function to clean up text data. If your product names are inconsistent—some are all uppercase, some are lowercase, or have extra spaces—you can easily normalize them all at once:
=MAP(A2:A11, LAMBDA(text, PROPER(TRIM(text))))
This formula trims ordinary excess spaces and converts each product name to title-style capitalization. TRIM removes leading and trailing ordinary spaces and reduces repeated ordinary spaces between words, while the PROPER function capitalizes the first letter of each word. The MAP function applies both functions simultaneously to every cell in the range.
Check the result with a small example
If B2:B4 contains 50, 100, and 200, the 10% markup formula returns 55, 110, and 220. The conditional formula returns 57.5, 110, and 220. Format the output as currency if needed; formatting changes how values display, not the underlying calculation.
The text-cleaning example changes blue notebook to Blue Notebook. Review names and acronyms afterward: PROPER can change intentional capitalization, and TRIM does not remove every kind of invisible character.
Where to enter the formula
Enter MAP once in an empty output cell with enough room for the result to spill. Keep the output outside an Excel table and clear any cells blocking its spill range. For multiple input ranges, use corresponding ranges of the same shape and keep the LAMBDA parameter count aligned with them.
Common errors and simpler alternatives
- #NAME?: check the Excel edition and spelling of MAP and LAMBDA.
- #VALUE! / Incorrect Parameters: check that the LAMBDA has one parameter per input array.
- #SPILL!: inspect the output area for occupied or merged cells and table placement.
- Formula not accepted: your regional settings may require semicolons instead of commas.
For simple multiplication, a direct dynamic-array expression such as =B2:B11*1.1 may be clearer. Use MAP when its item-by-item logic improves readability rather than adding it to every formula.
Reader Comments 0
Sign in with email or Google to join the discussion.