Jay*_*een 1 m powerquery powerbi
在Power BI中,我有一个M查询,用于测试列中的值是否等于或等于null.
当我添加语句[Sale.Revenue] <> null我得到一个错误,但它工作正常,[UserRole.Name] = null它工作正常.仅通过删除语句并将其添加回来进行测试.
We cannot convert the value null to type Logical.
这似乎应该工作,但只是无法搞清楚.
add_user_role_group = Table.AddColumn(
join_expand_sale,
"UserRole.Group1",
each (
if [UserRole.Name] = null and
[Sale.Revenue] <> null then
"Group1"
else if Text.Contains([UserRole.Name], "Manager") then
"Group2"
else
"Undefined"
)
)
Run Code Online (Sandbox Code Playgroud)
我确信它显然是明显的:/感谢您对此的看法.
其中一行的UserRole.Name和Sale.Revenue都具有空值.您需要明确检查,然后将其添加到"未定义"组.
发生的事情是第一个条件失败,因为Sale.Revenue为null.第二个条件调用Text.Contains,当[UserRole.Name]为null(Text.Contains返回可为空的逻辑值)时返回null.null不是true或false,因此您得到错误.
| 归档时间: |
|
| 查看次数: |
17310 次 |
| 最近记录: |