Forum Discussion
ValeriaBreve
Post Partisan
3 years agoFilter a list by any matching string from another list
Hello, I have a table with certain columns names, and I would like to remove some containing a defined string. An example below where I only used a string "budget" as I am not sure how to do it ...
- 3 years ago
Hello, ValeriaBreve I made it case insensitive. If you don't want that - remove comparer.
let ListTextToBeRemoved={"Plan","budget"}, column_names = {"2023 plan", "2023 budget", "2024 fact", "2023 fact", "222 BUDGET"}, ColumnstoBeRemoved = List.Select( column_names, each List.ContainsAny( {_}, ListTextToBeRemoved, (x, y) => Text.Contains(x, y, Comparer.OrdinalIgnoreCase))) in ColumnstoBeRemoved
AlienSx
Super User
3 years agoHello, ValeriaBreve I made it case insensitive. If you don't want that - remove comparer.
let
ListTextToBeRemoved={"Plan","budget"},
column_names = {"2023 plan", "2023 budget", "2024 fact", "2023 fact", "222 BUDGET"},
ColumnstoBeRemoved =
List.Select(
column_names,
each
List.ContainsAny(
{_},
ListTextToBeRemoved,
(x, y) => Text.Contains(x, y, Comparer.OrdinalIgnoreCase)))
in
ColumnstoBeRemoved
ValeriaBreve
Post Partisan
3 years agoAlienSx wdx223_Daniel Hello, thank you SO MUCH! I am still not mastering functions 😞 I hope it will come one day by learning and doing....
So just from a practical standpoint - I need to accept a solution only - I can't do for both - and you both replied so fast, thank you so much for this. I have decided to give the solution to AlienSx as there is the extra step of the case insensitivity - and I will give kudos to wdx223_Daniel - I hope this is OK!!!!!!
Thanks again, Valeria