• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

About Switch construction in power query

MBS

Member
I seek some explanation about how below code, especially code line "List.First(List.Select(values, each _{0}=input)){1}" get executed, for any input value say "XX123BYY". I got the results but dont understand how this code line get executes.
Also significance of {0} after each _.

Thanks.

= (input)=>
let
values = {
{"A", "Apple"},
{"B", "Boy"},
{"C", "Cat"},
{"D", "Dog"},
{"E", "Elephant"},
{"F", "Fox"},

{input, "Undefined"}
},
Result = List.First(List.Select(values, each _{0}=input)){1}
in
Result
 
What's the point of this? As long as input is different A~F. It will always return Undefined...

At any rate, values creates nested list with each list row containing pair {"A", "Apple"} etc.

List.Select iterates over the list and looking at first list element in the nested list to see if it matches "input".

Since it's nested list, List.First() will return the child list {input, "Undefined"}. Then taking 2nd element of the list ({2}). It returns "Undefined".
 
Back
Top