简体   繁体   English

Spotfire - 计算状态变化

[英]Spotfire - count a status change

And is it possible in Spotfire to use a calculated field to count a status change every time it changes from 0 to 1?是否可以在 Spotfire 中使用计算字段来计算每次从 0 变为 1 时的状态变化? eg if (previous row = 0 and current line =1, sum, else empty)例如,如果(前一行 = 0,当前行 = 1,总和,否则为空)

This is actually quite easy to do.这实际上很容易做到。

First step you need to get the value of the previous row.第一步,您需要获取前一行的值。 To do this, you need to use an aggregation and the OVER function.为此,您需要使用聚合和 OVER 函数。 For instance :例如 :

First([col2]) over (Previous([col1]))

Second step, you determine the previous value is 1 and the current is 0.第二步,您确定前一个值为 1,当前值为 0。

Third step, you need to perform a cumulative sum.第三步,您需要执行累加求和。 You can do all in one calculated column, but for more clarity I'll split it:您可以在一个计算列中完成所有操作,但为了更清楚,我将拆分它:

So your first intermediate column would be (let's name it TEMP):因此,您的第一个中间列将是(让我们将其命名为 TEMP):

if(([UTE-CALC]]=0) and (First([UTE-CALC]]) over (Previous([RowID]))=1),1,0)

And your final calculated column would perform the cumulative sum:并且您的最终计算列将执行累积总和:

If([UTE-CALC]=0,Sum([TEMP]) OVER (AllPrevious([RowID])))

Here you go:干得好: 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM