【问题标题】:Power Query M formula language foreign key checkingPower Query M 公式语言外键检查
【发布时间】:2021-11-17 21:28:39
【问题描述】:

我目前正在使用 Power BI Power Query 编辑器使用 Power Query M 公式语言编写查询。我目前有两个名为employeebusiness 的表。 employee 表的每一行都有一个business_id 连接到business 表的一行。我想运行 Table.SelectRows 函数以仅包含 employee.business_id = business.id 所在的行。

这是我目前所拥有的:

let
    Source = MySQL.Database(<DATABASE>, "business_database", [ReturnSingleDatabase=true, CreateNavigationProperties=false]),
    business_database_employee_all = Source{[Schema="business_database",Item="employee"]}[Data],
    employee_included = . . . Return all rows from employee where employee.business_id = business.id . . .
in
    employee_included

我们将不胜感激任何形式的帮助!我很愿意使用Table.SelectRows,但如果推荐的话,我会使用更好的功能!

【问题讨论】:

    标签: powerbi powerquery powerbi-desktop


    【解决方案1】:

    听起来您想要过滤员工表,以便它只显示业务表中的业务 ID 字段匹配的行

    最好的方法是将business表合并到employee表中,匹配business_id字段,内连接

    #"Merged Queries" = Table.NestedJoin(#"PriorStepNameinEmployeeTable",{"business_id"},business,{"business_id"},"business",JoinKind.Inner)
    

    另一种方式

    #"Select" = Table.SelectRows(#"PriorStepNameinEmployeeTable", each Table.Contains(business_table,_,{"business_id"}))
    

    【讨论】:

    • 这绝对是一个解决方案!但是,像这样的合并非常占用内存和存储空间。没有我可以使用 Table.SelectRows 的解决方案吗?
    • 已编辑以提供 Table.SelectRows 方法。不知道哪个强度较低
    • 这对你有用吗?
    • 成功了,非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 2021-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多