Forum Discussion
Spill formula with cell reference from lambda map
- May 15, 2025
New functions like DROP, TAKE and EXPAND (as well as HSTACK and VSTACK) can be used in place of OFFSET when working with dynamic arrays. Here's a couple examples, depending on your expected results for the last column of the dataset:
=LET( tbl; XLOOKUP(A2#&"|"&B1#;tbl_Data[Nummer]&"|"&tbl_Data[PostingDate];tbl_Data[Status];""); MAP(DROP(tbl;;-1);DROP(tbl;;1);LAMBDA(a;b;IF(a="Uitgebracht";SWITCH(b;"";"Vervallen";"Opdracht";"Nieuw";"");""))) )Note: tbl can simply reference B2#, but I changed the XLOOKUP formula to return "" if no match is found, so you don't have to deal with the #N/A errors.
=LET( tbl; XLOOKUP(A2#&"|"&B1#;tbl_Data[Nummer]&"|"&tbl_Data[PostingDate];tbl_Data[Status];""); MAP(tbl;EXPAND(DROP(tbl;;1);;COLUMNS(tbl);"");LAMBDA(a;b;IF(a="Uitgebracht";SWITCH(b;"";"Vervallen";"Opdracht";"Nieuw";"");""))) )Alternatively, with PIVOTBY as an all-in-one spill array:
=LET( pvt; PIVOTBY(tbl_Data[Nummer];tbl_Data[PostingDate];tbl_Data[Status];SINGLE;0;0;;0); tbl; DROP(pvt;1;1); arr; MAP(DROP(tbl;;-1);DROP(tbl;;1);LAMBDA(a;b;IF(a="Uitgebracht";SWITCH(b;"";"Vervallen";"Opdracht";"Nieuw";"");""))); HSTACK(EXPAND(pvt;;COLUMNS(pvt)+1;"");VSTACK(EXPAND("";;COLUMNS(arr);"");arr)) )Cheers!
New functions like DROP, TAKE and EXPAND (as well as HSTACK and VSTACK) can be used in place of OFFSET when working with dynamic arrays. Here's a couple examples, depending on your expected results for the last column of the dataset:
=LET(
tbl; XLOOKUP(A2#&"|"&B1#;tbl_Data[Nummer]&"|"&tbl_Data[PostingDate];tbl_Data[Status];"");
MAP(DROP(tbl;;-1);DROP(tbl;;1);LAMBDA(a;b;IF(a="Uitgebracht";SWITCH(b;"";"Vervallen";"Opdracht";"Nieuw";"");"")))
)Note: tbl can simply reference B2#, but I changed the XLOOKUP formula to return "" if no match is found, so you don't have to deal with the #N/A errors.
=LET(
tbl; XLOOKUP(A2#&"|"&B1#;tbl_Data[Nummer]&"|"&tbl_Data[PostingDate];tbl_Data[Status];"");
MAP(tbl;EXPAND(DROP(tbl;;1);;COLUMNS(tbl);"");LAMBDA(a;b;IF(a="Uitgebracht";SWITCH(b;"";"Vervallen";"Opdracht";"Nieuw";"");"")))
)Alternatively, with PIVOTBY as an all-in-one spill array:
=LET(
pvt; PIVOTBY(tbl_Data[Nummer];tbl_Data[PostingDate];tbl_Data[Status];SINGLE;0;0;;0);
tbl; DROP(pvt;1;1);
arr; MAP(DROP(tbl;;-1);DROP(tbl;;1);LAMBDA(a;b;IF(a="Uitgebracht";SWITCH(b;"";"Vervallen";"Opdracht";"Nieuw";"");"")));
HSTACK(EXPAND(pvt;;COLUMNS(pvt)+1;"");VSTACK(EXPAND("";;COLUMNS(arr);"");arr))
)Cheers!