Matchlists/tables 在电源查询中

Matchlists/tables in power query

我认为这必须有一个简单的答案,但我找不到任何示例。

我必须将列表的每个成员与子字符串列表进行比较,以查看该成员是否包含子字符串,如果包含 - return 子字符串与第三个列表的位置相同第一个列表的成员。

示例:

ListA = {"help me rhonda",  "in my room", "good vibrations", "god only knows"}
ListB = {"room", "me", "only"}

ListC should then should =  {"me", "room", null, "only"}

我是一名高级程序员,现在已经编写了大约 4 天的 M。这让我疯狂。我一直在尝试几种不同的功能,但到目前为止我还差得很远,所以我不会列出我的代码。 List.Transform 似乎是最有可能的选择,但我不太明白。

感谢您的帮助,

-J

单词交集

let
    ListA = {"help me rhonda",  "in my room", "good vibrations", "god only knows"},
    ListB = {"room", "me", "only"},
    intersect=List.Transform(ListA, (lineA)=>Text.Combine(List.Intersect({Text.Split(lineA, " "), ListB}), "|"))
in
    intersect

仅标记

let
    ListA = {"help me rhonda",  "in my room", "good vibrations", "god only knows"},
    ListB = {"room", "me", "only"},
    contains_word=List.Transform(ListA, (lineA)=>List.MatchesAny(ListB, (wordB)=>Text.Contains(lineA, wordB)))
in
    contains_word