[英]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.