Forum Discussion

JamesDuley's avatar
JamesDuley
Copper Contributor
Nov 16, 2022

Are references captured by LAMBDA converted to arrays?

Given the following formula, I expected both types to be the same, but I get "1 vs 64", what's going on here?

 

=LET(array, A1:A5,
    TYPE(INDEX(array,1,0))
    &
    " vs "
    &
    LAMBDA(TYPE(INDEX(array,1,0)))()
)

 

Are references captured by LAMBDA converted to arrays?

If so, is there a way I can force the first to be converted to an array too?

4 Replies

  • Patrick2788's avatar
    Patrick2788
    Silver Contributor

    JamesDuley 

    The INDEX is returning a scalar so TYPE returns a 1.

     

    This might work:

    =LET(array, A1:A5,TYPE(array)&" vs "&LAMBDA(TYPE(INDEX(array,1,0)))())
    • JamesDuley's avatar
      JamesDuley
      Copper Contributor
      That does make the types the same but doesn't select the first row like I need.

      I've now found that using CHOOSEROWS instead of INDEX always returns an array whether the input is a reference or not.
      • Patrick2788's avatar
        Patrick2788
        Silver Contributor
        CHOOSEROWS seems to calculate a bit faster than INDEX, too.
  • JamesDuley's avatar
    JamesDuley
    Copper Contributor
    To answer my second question, wrapping in VSTACK seems to do the trick.

Resources