Forum Discussion
Create a list from one column excluding values from another
- 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"
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"
Hello! This works great, I don't know how to thank you!
I tried to fiddle with the first formula for 1 h yesterday, but I just could not get there. I hope one day I'll be able to freeform formula this way :-). In the meantime, I am progressing in the reading of Miguel Escobar's PowerQuery book - if you have any other suggestions for learning this I am all ears.
Thanks again!!!!!!! 🙂
- lbendlin3 years agoSuper User
I would recommend you inhale Ben Gribaudo's M primer. It may be tough reading at times but absolutely worth it.
- ValeriaBreve3 years agoPost Partisan
Thanks! I was never pointed to this resource before - I will definitely read it!!!! 🙂