How to Use the MAP Function in Google Sheets | Apply a Formula to Every Element in an Array
What Is the MAP Function?
The MAP function applies a LAMBDA function sequentially to every element (cell by cell) in the specified arrays (cell ranges) and returns a new array of the same size. It is especially powerful when you want to batch-process functions like AND, OR, or JOIN that do not expand properly with standard ARRAYFORMULA.
Syntax
=MAP(array1, [array2, ...], LAMBDA(name1, [name2, ...], formula_expression))
- array1: The first cell range or array to process.
- array2, …: [Optional] Additional cell ranges of the same size to pass in.
- LAMBDA(…): The function to execute on each element. You must define the same number of parameters (
name1, name2, ...) as the number ofarrayarguments passed.
Example
Here is an example of checking whether both English scores (A2:A4) and Math scores (B2:B4) are 80 or higher to output "Pass" or "Fail" starting in cell C2 (MAP is ideal here because a standard ARRAYFORMULA would collapse AND into a single result).
| Row | Column A (English) | Column B (Math) | Formula in Column C | Column C (Result) |
|---|---|---|---|---|
| 1 | English | Math | Result | Result |
| 2 | 85 | 90 | =MAP(A2:A4, B2:B4, LAMBDA(eng, math, IF(AND(eng>=80, math>=80), "Pass", "Fail"))) |
Pass |
| 3 | 95 | 70 | (Auto-spilled) | Fail |
| 4 | 80 | 82 | (Auto-spilled) | Pass |
Common Errors and Notes
#VALUE!Error (Array Size Mismatch): When passing multiple ranges, all ranges must have the exact same number of rows and columns. Even a one-row difference causes a#VALUE!error.#ERROR!(LAMBDA Parameter Count Mismatch): If you pass two ranges toMAP, you must define exactly two parameters inLAMBDA. A mismatch triggers an error.#REF!Error: An error occurs if any cell in the spill range already contains a value.
Frequently Asked Questions
Q. What is the difference between ARRAYFORMULA and MAP?
A. ARRAYFORMULA fails to expand certain standard functions (such as AND, OR, or IFS) across arrays, whereas MAP lets you define custom logic with LAMBDA so complex conditional branching and calculations reliably apply to every element.
Q. Can I pass multiple ranges to MAP at the same time?
A. Yes. As long as the ranges are the same size, you can specify multiple ranges—such as =MAP(A2:A5, B2:B5, LAMBDA(a, b, a*b))—to process corresponding elements in pairs.