我有一张表,其中包含以下列发货日期,承诺日期
示例(假设当前日期是今天的日期,即“ 20/6/2019”):
Shipped_date Promise_date
20/1/2019 15/1/2019
Null 19/6/2019
Null 25/6/2019
我该如何设置一个if条件以提供输出
1- if shipped_date = null and promise_date < today's date then "yes"
2- if shipped_date = null and promise_date >= today's date then "no"
我尝试编写Dax代码,但当shipped_date具有值并且promise_date不是今天的日期时,我成功了另一种条件
if [JC_ShippedDate] < [PromiseDate] then "Completed early"
else if [JC_ShippedDate] > [PromiseDate] then "Completed behind schedule"
else if [JC_ShippedDate] = [PromiseDate] then "Completed on time" else "open"
错误是
Expression.Error: We cannot convert the value null to type Logical.
Details:
Value=
Type=Type
答案 0 :(得分:0)
不确定确切要查找的内容,但是在DAX中,类似这样的方法可以解决问题:
Test =
VAR Today =
NOW ()
RETURN
SWITCH (
TRUE (),
AND ( ISBLANK ( 'Table'[Shipped_Date] ), 'Table'[Promise_Date] < Today ), "Yes",
AND ( ISBLANK ( 'Table'[Shipped_Date] ), 'Table'[Promise_Date] >= Today ), "No",
'Table'[Shipped_Date] > 'Table'[Promise_Date], "x"
)
测试您的数据后,我得到以下信息: