• 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.

What am I doing wrong with nested lists?

Aaron.Lowrey

New Member
I am attempting to create a new column in a power query table. The table has two existing columns named “Day” and “ES”. Each column contains nested lists in their respective rows. I want to take the list from the “DAY” column for each row and transform it to a true/false list that compares each value in the Day list with the much shorter list in each “ES” row. I have attempted this with the following :

#”Added Custom3″ = Table.AddColumn(#”Added Custom2″, “Result”, each List.Transform([Day],
each List.Contains([ES],_)))

but this is not working as it produces a list for each item in “DAY” lists as “ERROR” When I use a similar code that reads a hard coded list, example {3,4,5}, the query works and produces a new nested list of true false values. the M code that works follows:

#”Added Custom3″ = Table.AddColumn(#”Added Custom2″, “Result”, each List.Transform([Day],
each List.Contains({3,4,5},_)))

What needs to change in my first code snippet so that it will work? I feel like this should be simpler. I have scoured tutorials and I believe I am missing something basic about working with nested lists.
 
Maybe try this:
#”Added Custom3″ = Table.AddColumn(#”Added Custom2″, "Custom", each List.Accumulate([DAY], {}, (s, c) => List.Combine({s, {List.Contains([ES], c)}})))
 
Back
Top