使用另一个表/列表过滤表,尽管匹配项必须作为包含进行,ie s sql像加入一样。这可以通过JOIN,DAX还是M?

发布于 2025-02-08 01:02:12 字数 3175 浏览 3 评论 0 原文

我有一张大型设备和第二个搜索词表。我想过滤设备列或组列中搜索的设备列表。我不确定PQ是否可以喜欢类似于SQL的加入,或者最好在DAX或M中进行此操作,无论如何我都是新手。我发现了一些在线示例,声称要做类似于我想要的事情,但是M代码令人困惑,根据帖子上的许多其他人,他们对解决方案的描述也没有意义。

谁能给我一些建议。我不确定在PQ中的性能会怎样。执行SQL查询会更好,但目前不是一个选择。

提前致谢。

例如:如果搜索列表由(“服务器”,“加载”,“ UK”)组成IE(“%服务器%”,“%load%”,“%uk%”)

搜索列表(命名范围 - 未固定的条目,可能为空): -

column1
服务器
加载
UK

设备表(100K+行): -

设备
1 EP1-UK NULL
2 UKG545DEV SERVER
3 3 L123 负载平衡器
4 L678 负载平衡器
5 cak.co.uk 站点
6 GBPRD996 备份
7 bltstlol draas
8 232.156 foo-uk-
9 server wack

4 7删除): -

设备
1 ep1-uk null
2 UKG545DEV Server3
3 L123 负载平衡器
4 L678 负载平衡器
5 cak.co.uk 站点
8 232.156 foo-uk-wack-wack
9 server4 感到无聊

。希望很简单。

I have a large table of devices and a second tiny table of search terms. I would like to filter the list of devices searching as a substring in the Device column or the Group column. I'm not sure if PQ can do Like Joins similar to SQL or if it is better to do this in DAX or M both of which I'm new to anyway. I've found a couple of online examples claiming to do something similar to what I want, but the M code was confusing and their descriptions on the solutions didn't make sense according to many others on the posts.

Can anyone give me some advice. I'm not sure what the performance will be like to do this in PQ. Executing a SQL query would be better, but isn't an option at present.

Thanks in advance.

E.g.: If the Search list is made up of ("server", "load", "uk") then I want to filter the Devices table on either the Device or Group columns looking for any row that contains them as case insensitive substrings, i.e. ("%server%", "%load%", "%uk%")

Search list (named range - not fixed number of entries, might be empty): -

Column1
server
load
uk

Devices table (100k+ rows): -

Row Device Group
1 EP1-uk null
2 UKG545DEV Server3
3 L123 Load Balancer
4 L678 Load Balancer
5 cak.co.uk Site
6 GBPRD996 Backup
7 BLTSTLOL DRaaS
8 232.156 Foo-UK-WACK
9 Server4 Got bored

Filtered Devices table (rows 6 and 7 removed): -

Row Device Group
1 EP1-uk null
2 UKG545DEV Server3
3 L123 Load Balancer
4 L678 Load Balancer
5 cak.co.uk Site
8 232.156 Foo-UK-WACK
9 Server4 Got bored

That's it. Hopefully simple.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

雨落□心尘 2025-02-15 01:02:12

是的,PQ支持加入。

的另一个示例:

这是加入您的参考 “灵活”匹配:
https://community.power.power.power.power.com.com/t5/desktop/合并WITH-WILDCARD/MP/581823

Yes, PQ supports joins.

This is another example for joining for your reference:

Excel MERGE two tables

For more “flexible” match:
https://community.powerbi.com/t5/Desktop/Merge-with-wildcards/m-p/581823

夜未央樱花落 2025-02-15 01:02:12

PQ具有模糊的加入,这可能是您想要的。

您可以选择手工制作自己的”喜欢“如果您真的需要加入。如果您发布示例数据和所需的输出,则有人会发布解决方案。

PQ has a fuzzy join which might be what you're looking for. https://support.microsoft.com/en-us/office/create-a-fuzzy-match-power-query-ffdd5082-c0c8-4c8e-a794-bd3962b90649

Alternatively, you can hand craft your own "like" join if you really need to. If you post sample data and desired output, someone will post a solution.

一片旧的回忆 2025-02-15 01:02:12

不知道这是多么有效,但是这将搜索所有列以查看它们是否包含查找列表中的任何文本,忽略了案例。然后,只需

通过(a)将行上的所有列组合到一个长文本(b)中来过滤该列的工作(c)(c)使用text.contains来转换搜索列表以找到匹配

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TestTable=Table.Buffer(Lookup), //name of your lookup table query
#"Added Custom" = Table.AddColumn(Source, "Custom",  each 
let test = Text.Combine(List.Transform(Record.ToList(_), each Text.From(_))," ") in  
List.AnyTrue( List.Transform(TestTable[Column1], each Text.Contains(test, _, Comparer.OrdinalIgnoreCase))))
in  #"Added Custom"

”

No idea how efficient this is, but this will search all columns to see if any of them contain any text from your lookup list, case ignored. Then just filter that column

Works by (a) combining all columns on the row into one long text (b) bringing in the search list (c) transforming the search list using Text.Contains to find a match

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
TestTable=Table.Buffer(Lookup), //name of your lookup table query
#"Added Custom" = Table.AddColumn(Source, "Custom",  each 
let test = Text.Combine(List.Transform(Record.ToList(_), each Text.From(_))," ") in  
List.AnyTrue( List.Transform(TestTable[Column1], each Text.Contains(test, _, Comparer.OrdinalIgnoreCase))))
in  #"Added Custom"

enter image description here

不再让梦枯萎 2025-02-15 01:02:12

如果您在SQL中执行此操作,则可以按照以下方式进行操作。您没有在这里加入。这是简单的过滤。

回复:性能 - 取决于您想做什么?是数据级还是分析级别?如果以后,则肯定会达克斯。如果事先,并且如果您有一个高级工作区,则将数据带到 datamart ,并且可以在此处应用完全合格的SQL。通常,DAX的性能比PQ出色。与SQL/DAX相同的方式,PQ无法扩展大数据。

select 
  * 
from 
  @t1 
where 
  c2 like '%server%' 
  or c2 like '%load%' 
  or c3 like '%server' 
  or c3 like '%load%'

可以在DAX查询中复制

Table =
CALCULATETABLE (
    Devices,
    CONTAINSSTRING ( Devices[Device], "server" )
        || CONTAINSSTRING ( Devices[Device], "load" )
        || CONTAINSSTRING ( Devices[Device], "uk" )
        || CONTAINSSTRING ( Devices[Group], "server" )
        || CONTAINSSTRING ( Devices[Group], "load" )
        || CONTAINSSTRING ( Devices[Group], "uk" )
)

“

或更好地通过措施

maxRow =
CALCULATE (
    MAX ( Devices[Row] ),
    FILTER (
        Devices,
        CONTAINSSTRING ( Devices[Device], SELECTEDVALUE ( CAT[Column1] ) )
            || CONTAINSSTRING ( Devices[Group], SELECTEDVALUE ( CAT[Column1] ) )
    )
)

Measure =
CALCULATE (
    MAX ( Devices[Row] ),
    GENERATE (
        CAT,
        FILTER (
            Devices,
            CONTAINSSTRING ( Devices[Device], CALCULATE ( MAX ( CAT[Column1] ) ) )
                || CONTAINSSTRING ( Devices[Group], CALCULATE ( MAX ( CAT[Column1] ) ) )
        )
    )
)

rel =“ nofollow noreferrer”>

If you do this in SQL you would do it the following way. You are not doing any join here. It is simple filtering.

Re: Performance - Depends on what you want to do? Is the is data-level or analysis-level? If later, then surely DAX. If prior and if you have a premium workspace take your data to datamart and you can apply fully qualified SQL there. In general, DAX has a much superior performance than PQ. PQ is not scalable with large data the same way SQL/DAX is.

select 
  * 
from 
  @t1 
where 
  c2 like '%server%' 
  or c2 like '%load%' 
  or c3 like '%server' 
  or c3 like '%load%'

s1

The same can be replicated in a Dax Query

Table =
CALCULATETABLE (
    Devices,
    CONTAINSSTRING ( Devices[Device], "server" )
        || CONTAINSSTRING ( Devices[Device], "load" )
        || CONTAINSSTRING ( Devices[Device], "uk" )
        || CONTAINSSTRING ( Devices[Group], "server" )
        || CONTAINSSTRING ( Devices[Group], "load" )
        || CONTAINSSTRING ( Devices[Group], "uk" )
)

s2

or better through a measure

maxRow =
CALCULATE (
    MAX ( Devices[Row] ),
    FILTER (
        Devices,
        CONTAINSSTRING ( Devices[Device], SELECTEDVALUE ( CAT[Column1] ) )
            || CONTAINSSTRING ( Devices[Group], SELECTEDVALUE ( CAT[Column1] ) )
    )
)

s3

ALL at once

Measure =
CALCULATE (
    MAX ( Devices[Row] ),
    GENERATE (
        CAT,
        FILTER (
            Devices,
            CONTAINSSTRING ( Devices[Device], CALCULATE ( MAX ( CAT[Column1] ) ) )
                || CONTAINSSTRING ( Devices[Group], CALCULATE ( MAX ( CAT[Column1] ) ) )
        )
    )
)

s4

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文