首页 > 解决方案 > 如何使用筛选器从另一个表的三列在 Power BI 中创建新表?

问题描述

我在索引列中有一个重复值的表,第三列仅在某些行中有值

我现在有的表:

我现在有的表

我的目标是创建一个新表,该表选择 CompanyID、开始日期和联系日期列,但从其中排除具有空白值的行

我想要的新表:

我想要的新桌子

我使用了以下 DAX 代码:

CALCULATETABLE (
    Table,
    FILTER ( Table, NOT ( ISBLANK ( Table[Start Date] ) ) )
)

这段代码的问题是它选择了我原始数据的所有 350 多列,而不是只选择我想要的 3 列。此外,我无法弄清楚如何添加其他过滤器,因此我没有联系日期和 ComapanyID 的空白行

我也尝试了下面的代码,但它不起作用

CALCULATETABLE (
    Table,
    FILTER ( Table, NOT ( ISBLANK ( Table[Start Date] ) ) ),
    FILTER ( Table, NOT ( ISBLANK ( Table[Order Date] ) ) ),
    FILTER ( Table, NOT ( ISBLANK ( Table[Employee Count] ) ) )
)

标签: powerbidax

解决方案


SELECTCOLUMNS 函数允许您选择特定的列。

例如:

New Filtered Table =
EVALUATE
SELECTCOLUMNS (
    CALCULATETABLE (
        Table,
        NOT ( ISBLANK ( Table[Start Date] ) ),
        NOT ( ISBLANK ( Table[Order Date] ) ),
        NOT ( ISBLANK ( Table[Employee Count] ) )
    ),
    "CompanyID", Table[CompanyID],
    "Contact Date", Table[Contact Date],
    "Start Date", Table[Start Date]
)

推荐阅读