尝试利用powerbi帮我计算日期。目前,如果“spend_start_Result”列有一个值,它正在正确计算,但如果此列没有值,它仍在计算并给我一个12/30/1899的日期。我的DAX代码有问题吗?
Arch_review_Calc =
IF (
Projects[spend_start_Result] = BLANK (),
0,
IF (
Projects[Complexity] = "Low",
Projects[spend_start_Result] - 45,
IF (
Projects[Complexity] = "Medium",
Projects[spend_start_Result] - 60,
IF ( Projects[Complexity] = "High", Projects[spend_start_Result] - 90, 0 )
)
)
)
如果该行中的spend_start_result列为空,我希望Arch_review_calc列在该行中为空。相反,它仍然在计算,我不确定我哪里出错了。
答案 0 :(得分:1)
您的代码用零替换空格,格式为日期。为避免这种情况,使用BLANK()函数代替零。
我会按如下方式重写您的公式:
Arch_review_Calc =
IF (
ISBLANK ( Projects[spend_start_Result] ), BLANK (),
SWITCH (
TRUE,
Projects[Complexity] = "Low", Projects[spend_start_Result] - 45,
Projects[Complexity] = "Medium", Projects[spend_start_Result] - 60,
Projects[Complexity] = "High", Projects[spend_start_Result] - 90,
BLANK ()
)
)
我不确定最后一个空格(在SWITCH语句中) - 如果你想要0而不是空白,用0替换BLANK()。