Forum Discussion

YeBoldeSquirrel's avatar
YeBoldeSquirrel
Copper Contributor
Feb 15, 2023
Solved

Spilling an array with given column and row cells

I'd like to create a formula that will use given column and row cells and spill an array. In this example the bold text would be given and the rest should automatically spill based on those: 

 

 Col1Col2Col3Col4Col5
Row1Col1Row1Col2Row1Col3Row1Col4Row1Col5Row1
Row2Col1Row2Col2Row2Col3Row2Col4Row2Col5Row2
Row3Col1Row3Col2Row3Col3Row3Col4Row3Col5Row3
Row4Col1Row4Col2Row4Col3Row4Col4Row4Col5Row4
Row5Col1Row5Col2Row5Col3Row5Col4Row5Col5Row5
Row6Col1Row6Col2Row6Col3Row6Col4Row6Col5Row6

 

I was thinking that this formula should work:

=MAP(C2:G2; B3:B8; LAMBDA(ColName; RowName; ColName&RowName))

 

It spills an array in the correct size, but produces "Value not Available" errors, except for the first cell.  

 Col1Col2Col3Col4Col5
Row1Col1Row1#N/A#N/A#N/A#N/A
Row2#N/A#N/A#N/A#N/A#N/A
Row3#N/A#N/A#N/A#N/A#N/A
Row4#N/A#N/A#N/A#N/A#N/A
Row5#N/A#N/A#N/A#N/A#N/A
Row6#N/A#N/A#N/A#N/A#N/A

 

Any ideas?

 

  • JosWoolley's avatar
    JosWoolley
    Feb 15, 2023

    YeBoldeSquirrel 

    It would be useful if you were to share an example of the type of calculation you're wishing to spill, as it might still be possible to do so without a LAMBDA-based function. Failing that, you could try MAKEARRAY, for example:

     

    =LET(
        a,B3:B8,
        b,C2:G2,
        MAKEARRAY(ROWS(a),COLUMNS(b),
        LAMBDA(x,y,LET(p,INDEX(b,y),q,INDEX(a,x),p&q))
        )
    )

     

    Regards

    • YeBoldeSquirrel's avatar
      YeBoldeSquirrel
      Copper Contributor
      Thanks Jos, for this simple example this would be it. In the actual problem I try to solve the column headers are some numbers, and the row labels some other numbers, and I'd like to do a complex calculation based on the combination of these two. I'd like to do this with a single array formula in the first cell, and not fill the whole grid with individual formulas.
      • JosWoolley's avatar
        JosWoolley
        Iron Contributor

        YeBoldeSquirrel 

        It would be useful if you were to share an example of the type of calculation you're wishing to spill, as it might still be possible to do so without a LAMBDA-based function. Failing that, you could try MAKEARRAY, for example:

         

        =LET(
            a,B3:B8,
            b,C2:G2,
            MAKEARRAY(ROWS(a),COLUMNS(b),
            LAMBDA(x,y,LET(p,INDEX(b,y),q,INDEX(a,x),p&q))
            )
        )

         

        Regards

Resources