电力查询中的匹配列表/表格(Matchlists/tables in power query)

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

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

例:

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

我是一名高级程序员,现在已经写了M大约4天了。 这让我疯狂。 我一直在尝试几种不同的功能,但到目前为止我还没有接近,所以我不打算列出我的代码。 List.Transform似乎是最可能的选择,但我不能完全解决它。

谢谢您的帮助,

-J

I'm thinking this has to have a simple answer, but I can't find any examples.

I have to compare every member of a list to a list of substrings to see if that member contains a substring, and if it does - return the substring to a third list at the same position as the member of the first list.

Example:

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

I'm an advanced programmer who has been writing M for about 4 days now. It's driving me crazy. I have been trying several different functions, but so far i'm not even close, so I'm not going to list my code. List.Transform seems the most likely option, but I can't quite work it out.

Thanks for the help,

-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

在此处输入图像描述

Words intersections

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

enter image description here

Flags only

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

enter image description here

更多推荐