超级查询中的匹配列表/表格 [英] Matchlists/tables in power query
问题描述
我认为这必须有一个简单的答案,但我找不到任何示例.
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.
示例:
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似乎是最有可能的选择,但我无法完全解决.
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.
感谢您的帮助
-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
这篇关于超级查询中的匹配列表/表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!