Forum Discussion
ValeriaBreve
3 years agoPost Partisan
Create a list from one column excluding values from another
Hello! I have a query (QueryA) with a text column. I am collecting a list of text strings from another query (QueryB), and from this list I need to exclude what starts with any of the text in the c...
- 3 years ago
Let me guess, you got your inspiration from Chris Webb's BI Blog: The List.* M Functions And The equationCriteria Argument Chris Webb's BI Blog (crossjoin.co.uk) ?
let Source = {"Apples", "Zebras", "Bananas", "Veggies"}, Select = List.Select(Source, each Table.RowCount(Table.SelectRows(QueryA, (k)=> Text.StartsWith( _ ,k[Column1])))=0) in Select - 3 years ago
let QueryB = {"Apples", "Zebras", "Bananas", "Veggies", "Pears", "Pea"}, Source = #table({"Text"}, {{"App"}, {"Pe"}, {"Ban"}, {"All Others"}}), #"Added Custom" = Table.AddColumn( Source, "Column list", (m) => if m[Text] = "All Others" then List.Select( QueryB, each Table.RowCount(Table.SelectRows(Source, (k) => Text.StartsWith(_, k[Text]))) = 0 ) else List.Select(QueryB, each Text.StartsWith(_, m[Text])) ) in #"Added Custom"
lbendlin
3 years agoSuper User
I would recommend you inhale Ben Gribaudo's M primer. It may be tough reading at times but absolutely worth it.
ValeriaBreve
3 years agoPost Partisan
Thanks! I was never pointed to this resource before - I will definitely read it!!!! 🙂