引用其先前值和当前值的计算列

Calculated column which references its previous value and current value

我有一个创建计算列的要求。此列需要使用它自己的先前值和当前值(即执行累积计算)。 我知道这在 Tableau 中可以通过使用函数

PREVIOUS_VALUE(-1)

所以我可以做类似

的事情
x (calc)  = sum(x(calc) + PREVIOUS_VALUE(-1))

如何在 Spotfire 中执行此操作?换句话说,

的等效 Spotfire 函数是什么

PREVIOUS_VALUE(-1) (from Tableau)

这是 excel 上的等效实现。其中 [WDVpt2] 是计算字段。

这是通过 OVER 函数完成的。您可以从 Tibco Documentation 中了解它们。您要查找的公式是:

(Sum([x]) over (AllPrevious([x]))) - [x]

Uses all nodes, including the current, from the start of the level. This can be used to calculate the cumulative sum.

我能够通过以下方法实现这一点。 Spotfire 的一个限制是计算列不能在之前的 node.In 画面查找中引用其值,并且 Previous_value 支持此功能(不要与 Spotfire 的 Previous() 混淆,后者可以应用于静态列 [x] 所以 [X_Calc]= [X_Calc]+ [X_Calc] over(AllPrevious([ROWID])) 是不可能的

第 1 步:创建一个基于 perdiod Rowid([YEAR]) 的 ROW ID 列

第 2 步:将每一行的结果分解为单独的计算列,因此第一行值为

First(Sum([WDVpt1]) over (AllPrevious([RowID])) - (Sum([WDVpt1]) over AllPrevious([RowID])) * [Policy rate])) over (AllPrevious([行号])))

第 3 步:使用之前计算的列为剩余期间(3 到 16)创建列 例如:- 节点 3 的列将使用 [WDVpt2_Year2] 节点 4 的列将使用 [WDVpt2_Year3] 等等 Sum(([RowID]=2 然后 [WDVpt1] 结束的情况) + Min([WDVpt1]) 在 ([RowID]) - ((([RowID]=2 然后 [WDVpt1] 结束的情况) + Min([WDVpt2_Year2]) over (intersect([asset class code],[RowID]))) * [Policy rate])) over (AllPrevious([RowID])))

Step4:写一个case语句生成一个单独的列

case when [RowID]=2 then first([WDVpt2_Year2]) when [RowID]=3 then first([WDVpt2_Year3]) when [RowID]=4 then first([ WDVpt2_Year4]) 当 [RowID]=5 然后首先([WDVpt2_Year5]) 当 [RowID]=6 然后首先([WDVpt2_Year6]) 当 [RowID]=7 然后首先( [WDVpt2_Year7]) when [RowID]=8 then first([WDVpt2_Year8]) when [RowID]=9 then first([WDVpt2_Year9]) when [RowID]=10 then first [WDVpt2_Year10]) when [RowID]=11 then first([WDVpt2_Year11]) when [RowID]=12 then first([WDVpt2_Year12]) when [RowID]=13 then first ([WDVpt2_Year13]) when [RowID]=14 then first([WDVpt2_Year14]) when [RowID]=15 then first([WDVpt2_Year15]) when [RowID]=16 then first([WDVpt2_Year16]) 结束为 [WDVpt2]