powerbi - 仅当另一列具有值 DAX 时 PowerBi 才计算日期
问题描述
试图利用 powerbi 帮助我计算日期。目前,如果“spend_start_Result”列有值,它正在正确计算,但如果该列没有值,它仍在计算并给我一个 1899 年 12 月 30 日的日期。我的 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 列为空白。相反,它仍在计算,我不确定我哪里出错了。
解决方案
您的代码用零替换空格,这些零被格式化为日期。为避免这种情况,请使用 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 而不是空白,请将 BLANK() 替换为 0。
推荐阅读
- react-native - 为什么反应原生 admob 在 RN v0.60.4 中不起作用?
- c# - C# TransactionScope 可以与 SSH.NET 一起使用吗?
- javascript - 如何解析json响应ajax
- c# - 微服务并按顺序处理收到的消息
- machine-learning - Sagemaker XG-Boost (objective=reg:logistic) 不适用于高度不平衡的数据集
- list - Flutter:`notifyListeners`不更新列表
- excel - excel中是否有一个选项可以根据第一个文档自动填充其他第二个文档?
- angular - 对于 Angular ngIf 异步/可观察状态更改错误,今天没有好的答案
- python - 是否可以复制本网站的 AJAX 调用?(网络抓取问题)
- r - tidyr complete() 是否使用 dplyr group_by() 函数?