Skip to content

BYROW

Runs a LAMBDA on each row of an array and returns one result per row, as a single column.

Syntax

=BYROW(, )

LAMBDA and LET

Excel for Microsoft 365, Excel 2024 and later, and Excel for the web. Not available in Excel 2021 or earlier.

Try it

Edit the formula in F2 or change the inputs. The sheet recalculates as you type.

F2
A
B
C
D
E
F
G
1
Product
Q1
Q2
Q3
2
Lamp
120
135
128
383
3
Arm
210
190
225
625
4
Hub
95
110
105
310
5
Cam
60
58
64
182
6

F2 =BYROW(B2:D5,LAMBDA(r,SUM(r))) returns 383; 625; 310; 182

How BYROW works

BYROW takes an array row by row, runs a calculation on each whole row and returns the answers as a column. It is the quick way to get a total, an average, a maximum or a test for every row at once, with one formula.

The arguments

  • array is the block to process. Every row of it is handed to the LAMBDA in turn.
  • lambda has one parameter, which holds one entire row. Inside the LAMBDA you treat that parameter as a range of cells: SUM(r), MAX(r), MIN(r), AVERAGE(r), TEXTJOIN(", ",TRUE,r).

=BYROW(B2:D5,LAMBDA(r,SUM(r))) returns the total of each product's three quarters, in four cells spilled down from the formula. The LAMBDA must return one value for each row. If it returns more than one, BYROW returns #CALC!.

Why use BYROW

Many functions collapse a whole range into one answer, so you can't hand them a table and get one answer per row. Copying a formula down a column is the old method. BYROW does it in one cell and doesn't need filling down as the table grows.

=BYROW(B2:D5,LAMBDA(r,MAX(r)-MIN(r))) gives the spread of each row. =BYROW(B2:D5,LAMBDA(r,SUM(--(r>100)))) counts the quarters above 100 in each row. Comparisons return TRUE and FALSE, and the double minus turns them into 1 and 0.

Filtering by a row condition

BYROW's best partner is FILTER. FILTER needs one TRUE or FALSE for each row, and BYROW produces exactly that:

=FILTER(A2:D5,BYROW(B2:D5,LAMBDA(r,MIN(r)>=100)))

This keeps the products for which every quarter reached 100. A row-wise condition such as "all", "none" or "at least two of" is difficult to write any other way.

BYROW, BYCOL and MAP

BYCOL does the same thing for columns. MAP works on each individual cell rather than each row. Pick the function that matches the shape of the question: a number for every row, a number for every column, or a number for every cell.

Notes

The result is one column with one cell per row of the input, and it spills. #SPILL! means the cells below the formula aren't empty. To add headers, put them above the formula or stack them: =VSTACK({"Total"},BYROW(...)). See LAMBDA for how to write the function.

BYROW needs Microsoft 365, Excel 2024 or later, or Excel for the web.

Arguments

array
The range or array whose rows you want to process, such as B2:D5.
lambda
A LAMBDA with one parameter. Each call receives a whole row of the array and must return a single value, such as LAMBDA(r,SUM(r)).

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Total of each row

F2 =BYROW(B2:D5,LAMBDA(r,SUM(r)))

Result: 383; 625; 310; 182

The LAMBDA receives one product's three quarters at a time. Lamp: 120 + 135 + 128 = 383.

F2
A
B
C
D
E
F
G
1
Product
Q1
Q2
Q3
2
Lamp
120
135
128
383
3
Arm
210
190
225
625
4
Hub
95
110
105
310
5
Cam
60
58
64
182
6

F2 =BYROW(B2:D5,LAMBDA(r,SUM(r))) returns 383; 625; 310; 182

Example 2

The spread between the best and worst quarter

F2 =BYROW(B2:D5,LAMBDA(r,MAX(r)-MIN(r)))

Result: 15; 35; 15; 6

MAX and MIN each look at one whole row. Arm ranges from 190 to 225, a spread of 35.

F2
A
B
C
D
E
F
G
1
Product
Q1
Q2
Q3
2
Lamp
120
135
128
15
3
Arm
210
190
225
35
4
Hub
95
110
105
15
5
Cam
60
58
64
6
6

F2 =BYROW(B2:D5,LAMBDA(r,MAX(r)-MIN(r))) returns 15; 35; 15; 6

Example 3

Count the quarters above 100 in each row

F2 =BYROW(B2:D5,LAMBDA(r,SUM(--(r>100))))

Result: 3; 3; 2; 0

r>100 gives TRUE or FALSE for each of the three quarters. The double minus turns those into 1 and 0, and SUM adds them.

F2
A
B
C
D
E
F
G
1
Product
Q1
Q2
Q3
2
Lamp
120
135
128
3
3
Arm
210
190
225
3
4
Hub
95
110
105
2
5
Cam
60
58
64
0
6

F2 =BYROW(B2:D5,LAMBDA(r,SUM(--(r>100)))) returns 3; 3; 2; 0

Example 4

Keep only the rows where every quarter reached 100

F2 =FILTER(A2:D5,BYROW(B2:D5,LAMBDA(r,MIN(r)>=100)))

Result: Lamp, 120, 135, 128; Arm, 210, 190, 225

BYROW gives FILTER one TRUE or FALSE for each product. Hub has a quarter of 95 and Cam of 60, so they are dropped.

F2
A
B
C
D
E
F
G
H
1
Product
Q1
Q2
Q3
2
Lamp
120
135
128
Lamp
120
135
3
Arm
210
190
225
Arm
210
190
4
Hub
95
110
105
5
Cam
60
58
64
6

F2 =FILTER(A2:D5,BYROW(B2:D5,LAMBDA(r,MIN(r)>=100))) returns Lamp, 120, 135, 128; Arm, 210, 190, 225

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In F2, return the total deals for each rep (the sum of B to D on each row) using BYROW.

Answer in F2.

F2
A
B
C
D
E
F
G
H
I
1
Rep
Jan
Feb
Mar
2
R-01
12
15
9
3
R-02
20
18
25
4
R-03
8
11
7
5
R-04
16
22
19
6
R-05
5
9
14
7
8
9
10

Common mistakes

  • The LAMBDA must return one value per row. Returning a list, such as a whole row, gives #CALC!.
  • The parameter holds the entire row. r>100 is a whole row of TRUE and FALSE values, so wrap it in SUM, AND or OR to get a single answer.
  • Comparisons produce TRUE and FALSE, which SUM ignores. Convert them with -- or *1 before adding.
  • Include only the numbers you want to process. If the first column holds labels, start the range at the first number column, as in B2:D5.
  • #SPILL! means the cells below the formula are not empty.

Questions people ask

What does BYROW do in Excel?

It runs a LAMBDA on each row of an array and returns one result per row. For example, `=BYROW(B2:D5,LAMBDA(r,SUM(r)))` returns the total of each row in one formula.

How do I get a total for every row without filling down?

Use `=BYROW(B2:D5,LAMBDA(r,SUM(r)))`. It spills one total per row, and it grows when you extend the range.

How do I filter rows based on a condition across several columns?

Pass a BYROW test to FILTER: `=FILTER(A2:D5,BYROW(B2:D5,LAMBDA(r,MIN(r)>=100)))` keeps the rows where every value is at least 100.

What is the difference between BYROW and BYCOL?

BYROW hands the LAMBDA one row at a time and returns a column of answers. BYCOL hands it one column at a time and returns a row of answers.

Does BYROW work in Excel 2021?

No. It is available in Microsoft 365, Excel 2024 and later, and Excel for the web. Earlier versions return `#NAME?`.

Learn BYROW in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.