Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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}
in
List.Skip( alist, (x)=>
Value.Is(x, type text) )
or
= let alist = {"a","b","c",2,2,2}
in
List.Select( alist, (x)=>
Value.Is(x, type text) )thes work as expected, but is you cause an error,
= let alist = {"a"+2,"a","c",2,2,2}
, skipper = List.Skip( alist, (x)=> not
Value.Is(x, type text) )
in skipperSo the first value = error which is not text , so why does it not skip this and then continue, and is there a way to skip or select non error values?
Richard
Solved! Go to Solution.
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
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.
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.
Thanks, yes I had tried nesting a try / otherwise within it and as you said it don't work.
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
Thanks, supprisingly tricky as it looks like quite a straighforward problem.
The basic issue is that lists don't have native error handling. If this is important to you please consider voting for an existing idea or raising a new one at https://ideas.fabric.microsoft.com
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 7 | |
| 6 |