Skip to content

Fix BYROW / MAP LAMBDA errors in Google Sheets (#N/A or #VALUE! from a lambda that returns the wrong shape)

Updated

BYROW runs a LAMBDA once per row and must get one value back each time. MAP runs a LAMBDA once per position and must get one value back, from arrays that are the same size. If the lambda returns a row, a SPLIT, or another array, Sheets errors — often #N/A or #VALUE!, tooltip Single value expected. Nested array results are not supported. If MAP’s inputs are different heights, the tooltip is Array arguments to MAP are of different size.

This page is BYROW / MAP shape. It is not ARRAYFORMULA empty 0 (blank × 2 prints 0 with no red triangle). It is not COUNTIFS range size (same “different size” sentence on a different function). English Google Sheets UI. Formula helper names stay English: LAMBDA, BYROW, MAP.

  1. Open a blank spreadsheet. In A1 type mon, B1 tue, C1 wed. A2 2, B2 2, C2 1. A3 0, B3 4, C3 3. A4 5, B4 1, C4 1. Hours per weekday, two more days omitted on purpose.

BYROW lambda returning the whole row. In E1 type byrow_row. In E2 enter =BYROW(A2:C4,LAMBDA(row,row)). The cell errors (#N/A / #VALUE!). Tooltip: Single value expected. Nested array results are not supported. row is already three cells. Returning row is an array per row. Leave E2 broken.

E2 selected. Formula bar shows =BYROW(A2:C4,LAMBDA(row,row)). E2 is #N/A. Tooltip: Single value expected. Nested array results are not supported.

The same BYROW returning one number. In E6 enter =BYROW(A2:C4,LAMBDA(row,SUM(row))). The formula spills 5, 7, 7 (row totals). That block is the control: one scalar per row.

MAP over mismatched arrays. In G1 type map_size. In G2 enter =MAP(A2:A4,B2:B5,LAMBDA(a,b,a+b)). A2:A4 is three rows. B2:B5 is four. The cell errors. Tooltip: Array arguments to MAP are of different size. Leave G2 broken.

G2 selected. Formula bar shows =MAP(A2:A4,B2:B5,LAMBDA(a,b,a+b)). G2 is #N/A. Tooltip: Array arguments to MAP are of different size.

MAP lambda returning an array. In G8 enter =MAP(A2:A4,LAMBDA(h,{h,h*2})). {h,h*2} is two columns. Nested array, same Single value expected tooltip. Leave G8 broken.

Wrong number of LAMBDA names. In I1 type names. In I2 enter =MAP(A2:A4,B2:B4,LAMBDA(a,a+1)). Two arrays, one name. Tooltip: Wrong number of arguments to LAMBDA. Leave I2 broken.

Confirm the working shape. E6 already spills three totals. If E2 errors and E6 spills, BYROW is fine and the lambda’s return is the bug.

  • BYROW groups each row to a scalar. LAMBDA(row,row) hands the row back. Nested arrays are not supported. SUM(row), AVERAGE(row), INDEX(row,1), TEXTJOIN(",",TRUE,row) each return one value. Those are legal.
  • MAP maps each position to a scalar. {h,h*2} is two values. SPLIT is N values. Same nested-array refusal.
  • MAP’s input arrays must match in height and width. Three cells next to four is Array arguments to MAP are of different size. That sentence also appears on COUNTIFS. The function here is MAP.
  • LAMBDA needs one name per input. BYROW always has one name (the row). MAP of two arrays needs two names. A missing name is #N/A with Wrong number of arguments to LAMBDA — not a hours bug.

This is not ARRAYFORMULA(A2:A4*2) writing 0 on blank hours. There is no error value on that page. See ARRAYFORMULA empty 0. E2 is a red error from shape, not a fake zero.

This is not FILTER mismatched heights. See FILTER range size. FILTER’s tooltip names FILTER and row counts.

This is not UNIQUE spill #REF!. See UNIQUE overwrite. The path can be empty and you still error if the lambda returns an array.

Leave E2, G2, G8, and I2 broken so the shape errors stay on the sheet. Leave E6 as the working totals.

Return one value from BYROW. Keep E6: =BYROW(A2:C4,LAMBDA(row,SUM(row))). For a blank-looking total when the row is all empty, =BYROW(A2:C4,LAMBDA(row,IF(COUNT(row)=0,"",SUM(row)))) — that is a scalar "", not an array. Do not return IF(...,row) (that would pass the row through and nest again).

E6 selected. Formula bar shows =BYROW(A2:C4,LAMBDA(row,SUM(row))). E6:E8 is 5, 7, 7 with no error triangle. E2 is still #N/A.

Same-size MAP. In H2 enter =MAP(A2:A4,B2:B4,LAMBDA(a,b,a+b)). The formula spills 4, 4, 6. Open columns: A2:A with B2:B, not A2:A4 next to B2:B.

One name per array. In I4 enter =MAP(A2:A4,B2:B4,LAMBDA(a,b,a+b)). Two names, two arrays.

Need several outputs per row? Do not return {sum, average} from BYROW — that is E2. Use one BYROW per metric, or MAKEARRAY.

Do not wrap E2 in IFERROR. You still have no total. See IFERROR vs IFNA. IFNA will not teach the lambda to return a scalar.

If BYROW / MAP errors and the hours are numbers, read the tooltip. Single value expected means the lambda spilled. Different size means the ranges. Wrong number of arguments means the LAMBDA names.

ARRAYFORMULA on a column is a different contract. Empty cells coerce to 0 in arithmetic, so A2:A4*2 writes a number into the blank row. That looks “filled.” It is not an error. The fix on that page is IF(A2:A4="","",…). See ARRAYFORMULA empty 0.

BYROW does not invent those zeros unless your lambda does math on blanks (SUM of a blank row is 0). If you want a blank total, return "" after a COUNT test. Nested row results are this page, not the 0-on-empty primer. Collapse first (SUM, INDEX, TEXTJOIN).