Applying calculations across multiple columns or multi-cell ranges in Google Sheets has historically required dragging formulas down thousands of rows or wrapping complex expressions inside ARRAYFORMULA. While ARRAYFORMULA functions well for simple mathematical additions, it fails when evaluating logical conditions (like IF, AND, OR) across multi-column records, forcing users into awkward workarounds.
Google Sheets introduced the MAP LAMBDA helper function to execute dynamic, cell-by-cell transformations. By mapping one or more arrays into a custom LAMBDA expression, MAP processes elements in parallel and spills a fully calculated matrix from a single top-level cell, updating dynamically as input rows expand.
Syntax and Parameters of the MAP Function
The MAP function accepts one or more arrays of identical dimensions and maps their corresponding values into a LAMBDA calculation:
=MAP(array1, [array2, ...], LAMBDA(val1, [val2, ...], expression))
- array1, array2: The ranges or dynamic arrays to be evaluated (for example,
A2:A50andB2:B50). - LAMBDA(val1, val2, expression): A custom anonymous function defining variable names for each corresponding array element and the mathematical expression or logical evaluation to execute.
Single-Column Transformations with MAP
Suppose column A2:A20 contains customer order values. To apply a progressive 15% discount only to orders exceeding £100 while keeping lower orders at standard price:
- Select cell
B2where the calculated column should start. - Enter the
MAPformula:
=MAP(A2:A20, LAMBDA(order, IF(order > 100, order * 0.85, order)))
Unlike ARRAYFORMULA, which often misinterprets logical IF evaluations across ranges, MAP evaluates each cell independently and spills a vertical vector of discounted prices.
Multi-Array Mapping Across Parallel Columns
The primary advantage of MAP over other helper functions like BYROW is its ability to ingest multiple separate arrays simultaneously:
- Suppose student test scores are in
B2:B30and practical assessment marks are inC2:C30. - To assign a composite grade where a student must score at least 50 in both categories to pass:
=MAP(B2:B30, C2:C30, LAMBDA(test, practical, IF(AND(test >= 50, practical >= 50), "Pass", "Retest")))
Google Sheets passes corresponding row pairs into the test and practical parameters sequentially, generating an accurate pass/retest ledger from a single formula cell.
Combining MAP with Text Formatting and String Cleaning
You can use MAP to sanitize and format messy imported contact data across multiple columns:
- Suppose first names reside in
A2:A50, surnames inB2:B50, and department codes inC2:C50. - To generate standardized corporate email aliases (e.g.
[email protected]in lowercase):
=MAP(A2:A50, B2:B50, LAMBDA(first, last, LOWER(LEFT(TRIM(first), 1) & "." & TRIM(last) & "@company.com")))
Best Practices and Preventing #SPILL! Errors
When implementing MAP across production Google Sheets models:
- Clear Destination Cells: Ensure all cells beneath the formula cell are empty. Any existing text, formatting borders, or manual entries in the spill path trigger a
#REF!spill error. - Equal Array Dimensions: When passing multiple arrays (e.g.
A2:A50andB2:B50), both ranges must contain the exact same number of rows and columns. Mismatched dimensions result in a#VALUE!argument error.