Why does BYROW() pass a 1x1 array to the LAMBDA rather than a scalar?

Consider the function:

=BYROW(SEQUENCE(10),LAMBDA(rw,rw+1))


The datatype of `rw` is 64, a 1x1 array, even though it is a single integer (datatype 1). This causes issues if the LAMBDA contains older, pre-array UDFs which expect a single, scalar value. eg for a UDF myFunc() which expects a single value, the array has to be flattened to a scalar explicitly using INDEX():

=BYROW(SEQUENCE(10),LAMBDA(rw,myFunc(INDEX(rw,1)))

Is there a case to made for BYROW to pass a scalar to the LAMBDA instead of a 1x1 array?


I suppose the problem is, by the name of the function, that a row is sent to the function, so that when that row is made of multiple columns there's little other way to send it but via an array (unless it's referring to a range of course).

That said, try:

=BYROW(SEQUENCE(10),LAMBDA(rw,myFunc(@rw)))

and say No to 'would you like to use this variation instead?'

This wouldn't work for multi-column ranges.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated February 11, 2025 Views 23 Applies to: