PowerQuery如果有多个条件和OR

时间:2017-08-17 07:17:39

标签: if-statement conditional-statements powerquery m

我如何在PowerQuery上复制它?

if(ATC[WorkitemAssetState]=64,
if(ATC[WorkitemIsClosed]=FALSE,
if(ATC[WorkitemIsDeleted]=FALSE,
if(ATC[M_WorkitemStatus]IN{"Reviewing","Available","Research","Progressing","Testing","Resolved","<none>"},
if(ATC[M_DefectResolutionId]IN {"-","<Unknown>","Resolution:1","Resolution:7"},1,-1)
,0)
,0)
,0)
,0)

我已完成以下操作,但似乎无法正常工作:

if [WorkitemAssetState]=64 and 
[WorkitemIsClosed]="FALSE" and
[WorkitemIsDeleted]="FALSE" and
[M_WorkitemStatus]="Reviewing" or [M_WorkitemStatus]= "Available" or [M_WorkitemStatus]= "Research" or [M_WorkitemStatus] = "Progressing" or [M_WorkitemStatus] = "Testing" or [M_WorkitemStatus] = "Resolved" or [M_WorkitemStatus] = "<none>" or [M_WorkitemStatus] = "<none>" or [M_WorkitemStatus] = "-" and
[M_DefectResolutionId]= "-" or [M_DefectResolutionId] = "<Unknown>" or [M_DefectResolutionId] = "Resolution:1" or[M_DefectResolutionId] = "Resolution:7" then 1 else 0

我很确定这是因为多个OR语句 由于FALSE,顺便说一下,我不会这么想。

谢谢!

1 个答案:

答案 0 :(得分:1)

如果您不确定“和”和“或”的优先级,最好使用括号。

事实上,首先评估“和”,然后评估“或”。 所以“a和b或c和d”等同于“(a和b)或(c和d)”。 不是“a和(b或c)和d”,我知道 - 你正在寻找。 如果是这样,您需要在“或”的集合周围添加括号。

假设您有逻辑值,那么“FALSE”将不起作用:您需要 false 不带引号且全部小写。

顺便说一句“似乎没有正常工作”并不是解释出错的首选方式。我猜你得到(差不多)所有1和(几乎)没有0?