Forum Discussion

uziel9999's avatar
uziel9999
Copper Contributor
Jun 16, 2022
Solved

Lambda with offset does not work with a sequence

Why does this work?   =LAMBDA(a, a)({1,2})     but not this?   =LAMBDA(a, OFFSET(a,0,0))({1,2})  
  • Lorenzo's avatar
    Lorenzo
    Jun 18, 2022

    uziel9999 

    Regarding my original question, my goal was to take a string, split it to an array, then iterate over that array and apply it to some logic. For example, RemoveAll(str, "a b c") would split "a b c" to the array {"a","b","c"} and remove those letters from the string (str)

     

    Cf. 1st post from PeterBartholomew1 on this discussion this could be something like (assuming you want to use FILTERXML):

    =LAMBDA(string, chars, [delim],
        LET(
            Delim, IF(ISOMITTED(delim), "," ,delim),
            ToRemove, FILTERXML(
                TEXTJOIN(,,"<t><w>",SUBSTITUTE(chars,Delim,"</w><w>"),"</w></t>"),
                "//w"
            ),
            REDUCE(string, ToRemove,
                LAMBDA(str,chr, SUBSTITUTE(str,chr,""))
            )
        )
    )

     

Resources