Forum Discussion
List.Remove (Matching) Items
- 11 months ago
The difference is that List.RemoveMatchingItems supports an optional equationCriteria function where you can define what "matching" means.
- 11 months ago
Hey!
Like lbendlin says with List.RemoveMatchingItems you have a little more control on how he sees matches. For example, if you have a list that randomly has some Uppercase and lowercase words, you can use a comparison criteria to make power query ignore Uppercases. See the code below:let // our list of names Source = { "Luke", "Leia", "C3PO", "R2D2", "Darth Vader", "Anakin Skywalker", "Leia", "Chewbacca" }, // the list with characters we want to remove RemoveList = { "r2d2", "LEia" }, // with Comparer.OrdinalIgnoreCase we can ignore all the uppercase letters so he matches correctly Result = List.RemoveMatchingItems( Source, RemoveList, Comparer.OrdinalIgnoreCase ) in ResultHopefully this explains it!
Hey!
Like lbendlin says with List.RemoveMatchingItems you have a little more control on how he sees matches. For example, if you have a list that randomly has some Uppercase and lowercase words, you can use a comparison criteria to make power query ignore Uppercases. See the code below:
let
// our list of names
Source = {
"Luke", "Leia",
"C3PO", "R2D2",
"Darth Vader", "Anakin Skywalker",
"Leia", "Chewbacca"
},
// the list with characters we want to remove
RemoveList = {
"r2d2",
"LEia"
},
// with Comparer.OrdinalIgnoreCase we can ignore all the uppercase letters so he matches correctly
Result = List.RemoveMatchingItems(
Source,
RemoveList,
Comparer.OrdinalIgnoreCase
)
in
Result
Hopefully this explains it!