Row totals
| A | B | C | |
|---|---|---|---|
| 1 | Q1 | Q2 | Q3 |
| 2 | 10 | 20 | 5 |
| 3 | 7 | 3 | 9 |
Formula: E2: =BYROW(A2:C3,LAMBDA(r,SUM(r)))
Result: Spills down: 35, 19
The first row adds up to 35 and the second to 19.
BYROW passes each row of a range to your LAMBDA in Google Sheets and returns one value per row.
BYROW(array, LAMBDA(row))MAP and BYCOL cover the element-wise and column-wise cases.
For a fuller explanation of the arguments and common errors, see the BYROW Excel guide.
| A | B | C | |
|---|---|---|---|
| 1 | Q1 | Q2 | Q3 |
| 2 | 10 | 20 | 5 |
| 3 | 7 | 3 | 9 |
Formula: E2: =BYROW(A2:C3,LAMBDA(r,SUM(r)))
Result: Spills down: 35, 19
The first row adds up to 35 and the second to 19.
| A | B | C | |
|---|---|---|---|
| 1 | Q1 | Q2 | Q3 |
| 2 | 10 | 20 | 5 |
| 3 | 7 | 3 | 9 |
Formula: E2: =BYROW(A2:C3,LAMBDA(r,MAX(r)-MIN(r)))
Result: Spills down: 15, 6
Row one spans 5 to 20, which is 15; row two spans 3 to 9, which is 6.
| A | B | C | |
|---|---|---|---|
| 1 | Q1 | Q2 | Q3 |
| 2 | 10 | 20 | 5 |
| 3 | 7 | 3 | 9 |
Formula: E2: =BYROW(A2:C3,LAMBDA(r,SUM(--(r>6))))
Result: Spills down: 2, 2
The comparison creates TRUE and FALSE values, the double minus turns them into 1 and 0, and SUM counts them.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =BYROW(C2:D4,LAMBDA(r,SUM(r)))
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Region | Product | Units | Price | Result | |
| 2 | East | Pen | 120 | 2.5 | 122.5 | |
| 3 | West | Pen | 80 | 2.5 | 82.5 | |
| 4 | East | Book | 45 | 12 | 57 | |
| 5 | North | Book | 60 | 12 | ||
| 6 | West | Lamp | 30 | 25 | ||
| 7 | East | Lamp | 15 | 25 |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page