Forum Discussion
List.FindText with items from a list?
- 2 years ago
Another approach, using List.Accumulate to cycle through the ListFilter:
let ListData= {"red apple", "blue apple", "green banana", "red pear"}, ListFilter={"apple","pear"}, filter = List.Accumulate( ListFilter, {}, (s,c)=> s & List.FindText(ListData,c)) in filter
ronrsnfld ZhangKun both your solutions work but only partially for me (which I know it's impossible). Still In my filter list I have items like "Q1". In my data list I have an item "2024 Q1" and it won't be returned. I checked the spelling, no trailing spaces...do you have an idea what might be happening? Thanks!
There may be something wrong with how you implemented my solution.
Adding the item "2024 Q1" to ListData and "Q1" to ListFilter includes "2024 Q1" in the returned list.
let
ListData= {"2024 Q1","red apple", "blue apple", "green banana", "red pear"},
ListFilter={"apple","Q1"},
filter = List.Accumulate(
ListFilter,
{},
(s,c)=> s & List.FindText(ListData,c))
in
filter
Results (as expected):
- ValeriaBreve2 years agoPost Partisan
ronrsnfld ZhangKun Thanks! I don't know what was happening... I did a couple of transformations to the ListData - which change nothing to items like "2024 Q1" - and now it works. Never seen this before, and I don't understand it. Anyway - again thanks - with this it works perfeclty 🙂