# MAP, BYROW and LAMBDA in Sheets (Google Sheets lesson 15 of 17)

> Run your own formula over every row, with one cell and no filling down.

Source: https://spreadsheetpractice.com/google-sheets/learn/map-lambda-byrow-sheets · Updated October 29, 2026

- **Course:** [Google Sheets course](https://spreadsheetpractice.com/google-sheets), track "Sheets power tools"
- **Time:** about 11 minutes, 2 graded exercises
- **Functions:** `MAP`, `BYROW`, `SCAN`, `LAMBDA`
- **Access:** Pro (the lesson text is free; the graded exercises need Pro)
- **Key formula:** `=MAP(B2:B6,C2:C6,LAMBDA(r,h,IF(h>40,40*r+(h-40)*r*1.5,h*r)))`: Pay with overtime for each row

## How it works

`LAMBDA(x, ...)` is a small function you define on the spot. Combine it with `MAP`, `BYROW` or `SCAN` to apply it across a range, and the results spill down by themselves.

`MAP(range1, range2, LAMBDA(a, b, ...))` goes through matching cells of one or more ranges, so overtime pay is one formula: pay the first 40 hours at the rate and the rest at 1.5 times. `BYROW` hands over a whole row at a time, and `SCAN` keeps a running result, which makes a running total.

It does the work of `ARRAYFORMULA` with `IF` when the rule is too long to write as one array expression.

## Syntax

| Formula | What it does |
|---|---|
| `=MAP(B2:B6,C2:C6,LAMBDA(r,h,IF(h>40,40*r+(h-40)*r*1.5,h*r)))` | Pay with overtime for each row |
| `=BYROW(B2:F6,LAMBDA(r,SUM(r)))` | One total per row |
| `=SCAN(0,B2:B7,LAMBDA(a,x,a+x))` | Running total |

## Watch out for

- The LAMBDA needs one parameter name for each range you pass to MAP.
- Keep the cells below the formula empty, or the spill is blocked.
- BYROW passes a whole row, so use SUM, MAX and friends inside; r*2 would not return a single value.

## The exercises

Solve them in the live grid at [MAP, BYROW and LAMBDA in Sheets](https://spreadsheetpractice.com/google-sheets/learn/map-lambda-byrow-sheets). Each answer is graded, then re-checked on changed data so typed-in numbers don't pass.

1. **Pay with overtime.** In D2, use MAP to calculate pay for each employee: hours up to 40 at the rate in column B, hours over 40 at 1.5 times the rate. Use B2:B6 (rate) and C2:C6 (hours) in one formula.
2. **Running total of hours.** In E2, use SCAN to return the running total of hours in C2:C6, starting from 0.

Previous: [QUERY: pivot, limit and text matching](https://spreadsheetpractice.com/google-sheets/learn/query-pivot-limit-contains) · Next: [SORTN, SEQUENCE and TRANSPOSE](https://spreadsheetpractice.com/google-sheets/learn/sortn-sequence-transpose)

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
