Forum Discussion

Dicken's avatar
Dicken
Icon for Post Prodigy rankPost Prodigy
9 months ago
Solved

Power Query List.Skip, Select

Can someone expalain why select / skip does not seem to handle errors,   I have read something about lazy evaluation whch causes the whole thing to fail; so ;  = let alist = {"a","b","c",2,2,2}...
  • lbendlin's avatar
    9 months ago
    let 
        alist  = {"a"+2,"a","c",2,2,2},
        #"Removed Errors" = Table.RemoveRowsWithErrors(Table.FromColumns({alist}))[Column1],
        skipper = List.Select( #"Removed Errors", each Value.Is(_, type text) ) 
    in skipper
  • AlienSx's avatar
    9 months ago

    Function arguments are evaluated eagerily before they passed to a function body. So that your can't even use try ... otherwise from within a function to go around the error when your "x" argument in List.Skip is error itself. You need to use somthing that may contain this error - e.g. a table. This is what lbendlin did. Another example is 

        Table.Skip(
            Table.FromColumns({{"a"+2,"a","c",2,2,2}}, {"lst"}),
            (x) => try x[lst] is text otherwise true
        )[lst]

    Read Ben Gribaudo's Primer for more info about error handling in M.