Going Stellar

Home/Google Sheets reference

Google Sheets function · Array

BYROW in Google Sheets: syntax and examples

BYROW hands each row of a range to a LAMBDA and collects the results in a column. It replaces a column of copied formulas with a single formula.

Syntax

BYROW(array_or_range, LAMBDA)

Arguments

ArgumentTypeRequiredWhat it does
array_or_rangerangeyesThe block of cells to process, one row at a time.
LAMBDAlambdayesA LAMBDA with one name: it receives a whole row and returns one value.

Examples

The examples use this table, starting in A1:

NameQ1Q2Q3
Ana102030
Bob51525
Cris789
=BYROW(B2:D4, LAMBDA(r, SUM(r)))

Result:

60
45
24

Row totals: one number per row, returned as a column.

Run in a Google Sheet (English US locale) on .

=BYROW(B2:D4, LAMBDA(r, MAX(r)))

Result:

30
25
9

The best quarter of each person.

Run in a Google Sheet (English US locale) on .

=BYROW(B2:D4, LAMBDA(r, AVERAGE(r)))

Result:

20
15
8

Average per row.

Run in a Google Sheet (English US locale) on .

=BYROW(B2:D4, LAMBDA(r, IF(SUM(r)>50, "high", "low")))

Result:

high
low
low

A label per row, based on its total.

Run in a Google Sheet (English US locale) on .

=BYROW(B2:D4, LAMBDA(r, COUNTIF(r, ">9")))

Result:

3
2
0

How many quarters per person are above 9.

Run in a Google Sheet (English US locale) on .

Common errors

  • The LAMBDA takes exactly one name, the row. A LAMBDA with two names, as in LAMBDA(r, c, SUM(r)), returns #N/A.
  • The second argument has to be a LAMBDA. Passing a bare function name such as SUM returns #N/A.
  • The output is always one column with one cell per input row, however many columns the range has.

Compared with Excel

Same syntax in Excel 365, where BYROW is also available.

Sources

  1. BYROW (Docs Editors Help)

Markdown version · All functions