Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Dicken
Continued Contributor
Continued Contributor

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} 
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 skipper

So   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


2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

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

View solution in original post

AlienSx
Super User
Super User

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. 

View solution in original post

5 REPLIES 5
AlienSx
Super User
Super User

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. 

Dicken
Continued Contributor
Continued Contributor

Thanks, yes I had tried nesting a try / otherwise within it and as you said it don't work. 

lbendlin
Super User
Super User

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
Dicken
Continued Contributor
Continued Contributor

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.