Spotfire案例声明不起作用

时间:2017-06-22 12:00:42

标签: data-analysis spotfire case-statement

我正在尝试编写一个case语句,我希望将列值分类为4个案例。但只创造了一个案例 - " HV-HM"。代码是:

case 
WHEN Sum([Sales])/UniqueCount([Quarter])>=${HighVolume} and Avg([Net 
Margin])>=${HighMargin} THEN "HV-HM"
WHEN Sum([Sales])/UniqueCount([Quarter])>=${HighVolume} and (Avg([Net 
Margin])<${HighMargin}) and Avg([Net Margin])>${LosingMargin} THEN "HV-LM"
WHEN Sum([Sales])/UniqueCount([Quarter])<${HighVolume} And Avg([Net Margin])
<${HighMargin} And Avg([Net Margin])>${LosingMargin} THEN "LV-LM"
WHEN Avg([Net Margin])<=${LosingMargin} THEN "Losing"
END as [Sector]

有人可以解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

评论太久......

您的对帐单中的每个案例都是唯一的,这意味着您的所有数据都符合第一个“案例”。由于您认为不应该是这种情况,最好的办法是将其分解为计算列,以便您可以看到值。为每个案例创建一个计算列。

为这两种方法创建计算列:

Sum([Sales])/UniqueCount([Quarter])
Avg([Net Margin])

然后,您可以手动查看它们是高于还是低于您的高和低保证金属性控件。

您还可以为每种情况创建一个计算列:

case when Sum([Sales])/UniqueCount([Quarter])>=${HighVolume} and Avg([Net Margin])>=${HighMargin} then 1 end as [Test 1]
case when Sum([Sales])/UniqueCount([Quarter])>=${HighVolume} and (Avg([Net Margin])<${HighMargin}) and Avg([Net Margin])>${LosingMargin} 1 end as [Test 2]
etc...