简体   繁体   English

如何在加入一对多时在Power BI中用NULL替换NULL

[英]How to substitute NULL with value in Power BI when joining one to many

In my model I have table AssignedToUser that don't contain any NULL values. 在我的模型中,我有表AssignedToUser ,它不包含任何NULL值。 Table TotalCounts contains number of tasks for each User. TotalCounts包含每个用户的任务数。

Those two table joined on UserGUID, and table TotalCounts contains NULL value for UserGUID. 这两个表连接在UserGUID上,表TotalCounts包含UserGUID的NULL值。

在此输入图像描述

When I drop everything in one table there is NULL value for AssignedToUser . 当我将所有内容放在一个表中时, AssignedToUser值为NULL。 How can I substitute value NULL for AssignedToUser for "POOL". 如何将AssignedToUser的值NULL替换为“POOL”。

在此输入图像描述

Under EditQuery I tried to Create additional column 在EditQuery下,我尝试创建其他列

if [AssignedToUser] = null then "POOL" else [AssignedToUser]

But that didnt help. 但那并没有帮助。

UPDATE: Thanks Alexis. 更新:谢谢Alexis。 I have created FullAssignedToUsers table, but when I try to make a relationship with TotalCounts on UserGUID - it doesnt like it. 我已经创建了FullAssignedToUsers表,但是当我尝试在UserGUID上与TotalCounts建立关系时 - 它不喜欢它。

在此输入图像描述

Data in new a table looks like this: 新表中的数据如下所示:

在此输入图像描述

UPDATE: File .ipbx can be accessed here: 更新:文件.ipbx可以在这里访问:

https://www.dropbox.com/s/95frggpaq6tce7q/User%20Open%20Closed%20Tasks%20Experiment.pbix?dl=0 https://www.dropbox.com/s/95frggpaq6tce7q/User%20Open%20Closed%20Tasks%20Experiment.pbix?dl=0

I believe the problem here is that your join has UserGUID values that are not in your AssignedToUsers table. 我相信这里的问题是你的join的UserGUID值不在你的AssignedToUsers表中。

To correct this, one possibility is to replace your AssignedToUsers table with one that contains all the UserGUID values from the TotalCounts table. 为了解决这个问题,一种可能性是,以取代AssignedToUsers一个包含所有表UserGUID从值TotalCounts表。

FullAssignedToUsers =
    ADDCOLUMNS(VALUES(TotalCounts[UserGUID]),
        "AssignedToUser",
        LOOKUPVALUE(AssignedToUsers[AssignedToUser],
            AssignedToUsers[UserGUID], TotalCounts[UserGUID]))

The should get you the full outer join. 应该让你完整的外部联接。 You can then create the custom column like you described in the table and use that column in your visual. 然后,您可以按照表中所述创建自定义列,并在视觉中使用该列。

You'll probably want to break the relationships with the original AssignedToUsers table and create relationships with the new one instead. 您可能希望打破与原始AssignedToUsers表的关系,并创建与新的关系。

If you don't want to take that extra step, you can do an ISBLANK inside your new table formula. 如果您不想采取额外步骤,可以在新表公式中执行ISBLANK

FullAssignedToUsers =
    ADDCOLUMNS(VALUES(TotalCounts[UserGUID]),
        "AssignedToUser",
        IF(
            ISBLANK(
                LOOKUPVALUE(AssignedToUsers[AssignedToUser],
                    AssignedToUsers[UserGUID], TotalCounts[UserGUID])),
            "POOL",
            LOOKUPVALUE(AssignedToUsers[AssignedToUser],
                AssignedToUsers[UserGUID], TotalCounts[UserGUID])))

Note: This is equivalent to doing a right outer join merge on the AssignedToUsers table in the query editor and then replacing the nulls with "POOL". 注意:这相当于在查询编辑器中对AssignedToUsers表执行右外连接合并,然后将空值替换为“POOL”。 I'd actually recommend approaching it that way instead. 我实际上建议那样接近它。


Another way to approach it is to pull the AssignedToUser column over to the TotalCounts table in a custom column and use that column in your visual instead. 接近它的另一种方法是将AssignedToUser列拉到自定义列中的TotalCounts表,并在视觉中使用该列。

AssignedToUsers =
    IF(ISBLANK(RELATED(AssignedToUsers[AssignedToUser])),
       "POOL",
       RELATED(AssignedToUsers[AssignedToUser]))

This is equivalent to doing a left outer join merge on the TotalCounts table in the query editor, expanding the AssignedToUser column, then replacing nulls with "POOL" in that column. 这相当于在查询编辑器中的TotalCounts表上执行左外连接合并,展开AssignedToUser列,然后用该列中的“POOL”替换空值。

In Dax missing values are Blank() not null. 在Dax中,缺失值为Blank()而不是null。 Try this: 试试这个:

=IF(
    ISBLANK(AssignedToUsers[AssignedToUser]),
    "Pool",
    AssignedToUsers[AssignedToUser]
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我们对power bi表中的列值求和时,如果值为null或空白,那么如何在power中显示为0? - When we sum column value in power bi table, if value is null or blank then how to show it as 0 in power? 如何通过 Power BI DirectQuery 从多对一相关表中获取映射值? - How can I get a mapped value from a many-to-one related table via Power BI DirectQuery? 如何在 Power BI 中的多对多关系中引用正确的值? - How to reference the correct value in a many to many relationship in Power BI? 如何用递增值替换图表上的用户名,但 Power BI 中切片器上的值除外 - How to substitute user names on a chart with incrementing value except value on a slicer in Power BI 如何检查Power BI中的category值是否为null? - How can I check if a categories value is null in Power BI? power BI 显示一个值 - power BI diaplay one value 如何用功率 bi 中的产品平均值填充 null 值 - How to fill the null value with product average in power bi 如何使 power bi 与多对多一起工作? - How to make power bi work with many to many? 在 Power BI 中仅编辑一个单元格的值 - Editing value of just one cell in Power BI 通过 Power BI (DAX) 中的多对一关系从相关表中返回汇总值 - Return a summarized value from a related table via a many to one relationship in Power BI (DAX)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM