ID EN
#Dynamic array

BYROW

Excel Functions

Apply function to row

Syntax

EXCEL
=BYROW(array, function)

Arguments

Parameter Description
array The range or array to process.
function The function to apply to each row.

Return Value

One result per row

Details

The BYROW function applies a function to each row in array and returns one result per row in a single array. For example, if BYROW is given a range with 10 rows, it returns an array of 10 results, one per row. The calculation performed on each row can be a built-in function like SUM or COUNT, or a custom LAMBDA function that operates on row values. BYROW is especially useful in three situations: See below for specific examples. BYROW takes two arguments: an array to process and a function to run on each row. The function can be written in two ways. The first way is as a long-form custom LAMBDA. This is the general form, and the one you'll see whenever the calculation needs custom logic: The second way is a short-form "eta lambda" syntax. Instead of wrapping the function in a LAMBDA, you pa

Examples

Basic usage

BYROW takes two arguments: an array to process and a function to run on each row. The function can be written in two ways. The first way is as a long-

EXCEL
=BYROW(array,LAMBDA(row,SUM(row)))
=BYROW(array,LAMBDA(row,AVERAGE(IF(row<>0,row))))
=BYROW(array,LAMBDA(row,MAX(row)-MIN(row)))
Basic usage

The second way is a short-form "eta lambda" syntax. Instead of wrapping the function in a LAMBDA, you pass just the function name. This works for sing

EXCEL
=BYROW(array,SUM) // sum each row
=BYROW(array,MAX) // max of each row
=BYROW(array,AVERAGE) // average of each row
=BYROW(array,COUNTA) // count of non-empty values
Sum each row

In the worksheet below, the goal is to sum the values in each row of the range C5:H15. The formula in J5 is:

EXCEL
=BYROW(C5:H15,SUM)
Sum each row

BYROW processes all 11 rows at once and returns an array of 11 sums that spill into J5:J15. The same pattern works for any single-argument aggregate:

EXCEL
=BYROW(C5:H15,MAX) // max of each row
=BYROW(C5:H15,MIN) // min of each row
=BYROW(C5:H15,AVERAGE) // average of each row
Count values per row that meet a condition

BYROW is useful when you want to count values per row that meet one or more specific conditions. This is where the eta syntax breaks down and the full

EXCEL
=BYROW(C5:H15,LAMBDA(row,SUM(--(row>90))))
Average each row ignoring zeros

Zeros sometimes mean "no data" rather than "a real value of zero" (a store that wasn't open, a test that wasn't taken, a product that wasn't stocked).

EXCEL
=BYROW(C5:G15,LAMBDA(row,AVERAGE(IF(row<>0,row))))

See Also

LAMBDA LET MAP SCAN REDUCE MAKEARRAY BYCOL