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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Dicken
Post Prodigy
Post Prodigy

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. 

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

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.