Category: FUNCTION | Updated: 2026-11-22
How to Use the BYROW Function in Google Sheets | Aggregate and Calculate Row by Row
What Is the BYROW Function?
The BYROW function splits a specified table (cell range) row by row, applies a calculation defined by a LAMBDA function (such as sum, maximum, or string concatenation) to each row, and returns the results as a single vertical column array. It saves you from having to drag or copy row-level summary formulas down the sheet.
Syntax
=BYROW(array, LAMBDA(row, formula_expression))
- array: The cell range or array to calculate row by row.
- LAMBDA(row, formula_expression): The calculation applied to each row. The
rowparameter receives one row’s range at a time.
Example
Here is an example of calculating each student’s total score across three subjects (A2:C4) in a single formula starting at cell D2.
| Row | Column A (Japanese) | Column B (Math) | Column C (English) | Formula in Column D | Column D (Total) |
|---|---|---|---|---|---|
| 1 | Japanese | Math | English | Total | Total |
| 2 | 80 | 75 | 90 | =BYROW(A2:C4, LAMBDA(r, SUM(r))) |
245 |
| 3 | 65 | 85 | 70 | (Auto-spilled) | 220 |
| 4 | 90 | 95 | 88 | (Auto-spilled) | 273 |
Common Errors and Notes
#VALUE!Error (Not Returning a Single Value): The formula insideLAMBDAmust return exactly one value (a scalar) per row. For example, writingLAMBDA(r, r*2)returns a multi-column array and causes an error.#REF!Error (Spill Range Conflict): Because results spill down into a single vertical column, a#REF!error occurs if cells below the formula cell already contain other values.- Useful for Text Joining Too: Beyond numeric aggregation, you can use
=BYROW(A2:C4, LAMBDA(r, TEXTJOIN("-", TRUE, r)))to join text across each row with hyphens in one batch.
Frequently Asked Questions
Q. How do I write a BYROW formula to calculate row-by-row totals?
A. Write =BYROW(A2:C10, LAMBDA(row, SUM(row))). This outputs the sum of each row from row 2 to row 10 in a single vertical column.
Q. Can the LAMBDA inside BYROW return multiple columns for a single row?
A. No. BYROW must return exactly one value (a single scalar result) per row. Returning a multi-column array results in a #VALUE! error.