首页 > 解决方案 > 如何将tableau中的ifnull语句转换为powerbi dax?

问题描述

我正在处理从 tableau 到 power bi 的仪表板转换。卡在 tableau 中需要使用 dax 转换为 powerbi 的计算维度!

通过替换 tableau 中的 IFNULL 语句。我已经尝试使用 IF 语句在 dax 中使用 ISBLANK 参数,该语句应该检查该字段是否返回空值。我对 dax 的了解是有限的,我想这个问题真的很简单,但我坚持了好几个小时。

需要转换成powerbi的tableau代码:

if LEFT([Supplier Code],1) = "E" then "Employees Claims" else 
IF 
IFNULL(IFNULL([ASL Supplier (SWPS)],IFNULL([Supplier Name],IFNULL([Vendor],[Supplier Code]))),'Not Define')= 'N/A'
THEN IFNULL([Vendor],[Supplier Name]) ELSE
IFNULL(IFNULL([ASL Supplier (SWPS)],IFNULL([Supplier Name],IFNULL([Vendor],[Supplier Code]))),'Not Define') 
END
END

我尝试过的 Power bi 代码:

Supplier (swps) = IF(LEFT([Supplier Code],1) = "E", "Employee Claims",
IF(
IF(ISBLANK(V_FIPnLDashboard_Tne[ASL Supplier (SWPS)]),ISBLANK(V_FIPnLDashboard_Tne[Supplier Name]),ISBLANK(V_FIPnLDashboard_Tne[Supplier Code])),"Not Define") = "N/A")

我的代码不完整,因为我无法理解 tableau 中代码的完整分解。

画面:

if LEFT([Supplier Code],1) = "E" then "Employees Claims" else 
IF 
IFNULL(IFNULL([ASL Supplier (SWPS)],IFNULL([Supplier Name],IFNULL([Vendor],[Supplier Code]))),'Not Define')= 'N/A'
THEN IFNULL([Vendor],[Supplier Name]) ELSE
IFNULL(IFNULL([ASL Supplier (SWPS)],IFNULL([Supplier Name],IFNULL([Vendor],[Supplier Code]))),'Not Define') 
END
END

预期结果是一个维度/列,其值作为幂 bi 中的给定条件。

标签: if-statementpowerbitableau-apidaxifnull

解决方案


IF IFNULL([ASL Supplier(SWPS)],IFNULL([Supplier(SWPS)],IFNULL([Vendor],IFNULL([Supplier Code],'Not Define')))) = 'N/A'
THEN [Supplier(SWPS)] 
ELSE IFNULL([ASL Supplier (SWPS)],IFNULL([Supplier(SWPS)],IFNULL([Vendor],IFNULL([Supplier Code],'Not Define'))))
END

推荐阅读