Share via

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

Anonymous
2024-06-11T17:09:07+00:00

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?

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-06-11T20:23:18+00:00

    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 answer helpful?

    0 comments No comments