我正在将仪表板从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中的给定条件。
答案 0 :(得分:0)
在您的示例中,我发现分解Tableau代码的原始逻辑最有用:
鉴于此,DAX公式为:
Supplier (swps) =
VAR vendorOrSupplier =
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Vendor] ),
V_FIPnLDashboard_Tne[Supplier Name],
V_FIPnLDashboard_Tne[Vendor]
)
VAR firstValidField =
IF (
ISBLANK ( V_FIPnLDashboard_Tne[ASL Supplier (SWPS)] ),
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Supplier Name] ),
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Vendor] ),
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Supplier Code] ),
"Not Defined",
V_FIPnLDashboard_Tne[Supplier Code]
),
V_FIPnLDashboard_Tne[Vendor]
),
V_FIPnLDashboard_Tne[Supplier Name]
),
V_FIPnLDashboard_Tne[ASL Supplier (SWPS)]
)
VAR allBlank =
IF ( firstValidField = "Not Defined", TRUE (), FALSE () )
RETURN
IF (
LEFT ( V_FIPnLDashboard_Tne[Supplier Code], 1 ) = "E",
"Employee Claims",
IF (
V_FIPnLDashboard_Tne[ASL Supplier (SWPS)] = "N/A",
vendorOrSupplier,
IF (
ISBLANK ( V_FIPnLDashboard_Tne[ASL Supplier (SWPS)] ),
IF (
V_FIPnLDashboard_Tne[Supplier Name] = "N/A",
vendorOrSupplier,
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Supplier Name] ),
IF (
V_FIPnLDashboard_Tne[Vendor] = "N/A",
vendorOrSupplier,
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Vendor] ),
IF ( [Supplier Code] = "N/A", vendorOrSupplier, firstValidField ),
firstValidField
)
),
firstValidField
)
),
firstValidField
)
)
)
答案 1 :(得分:0)
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
答案 2 :(得分:0)
supplier = var supplierswps =
`IF (
ISBLANK (V_FIPnLDashboard_Tne[ASL Supplier(SWPS)]),
IF (
ISBLANK (V_FIPnLDashboard_Tne [Supplier (SWPS)]),
IF (
ISBLANK ( V_FIPnLDashboard_Tne[Vendor] ),
IF (
ISBLANK (V_FIPnLDashboard_Tne [Supplier Code]),"Not Define")))= "N/A",V_FIPnLDashboard_Tne[Supplier (swps)])
var supplierswpsfalse = IF(supplierswps = "Not define", TRUE(), FALSE())
return
if(
ISBLANK(V_FIPnLDashboard_Tne[ASL Supplier (SWPS)] ),
IF (
ISBLANK (V_FIPnLDashboard_Tne[Supplier (SWPS)]),
IF(
ISBLANK ( V_FIPnLDashboard_Tne[Vendor] ),
IF (
ISBLANK (V_FIPnLDashboard_Tne[Supplier Code] )
,"Not Define",
V_FIPnLDashboard_Tne[Supplier Code]
),
`
V_FIPnLDashboard_Tne[Vendor]
),V_FIPnLDashboard_Tne[Supplier (SWPS)]
),V_FIPnLDashboard_TnE[ASL Supplier (SWPS)]
)