Power Bi:if Condition with multiple cases specialized with date = NULL or SYSDATE
Power Bi : if Condition with multiple cases specially with date = NULL or SYSDATE
我有一个 table 包含这些列 shipped_date、Promise_date
示例(假设当前日期是今天的日期“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
不确定您要找的到底是什么,但在 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"
)
对您的数据进行测试后,我得到以下信息:
我有一个 table 包含这些列 shipped_date、Promise_date
示例(假设当前日期是今天的日期“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
不确定您要找的到底是什么,但在 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"
)
对您的数据进行测试后,我得到以下信息: