简体   繁体   English

Spotfire 计算相对于前一行值的差异

[英]Spotfire calculate difference with respect to previous row value

I have a data as below.我有一个数据如下。 I have created column "difference in values" manually, the calculation is value at 8:15 AM - value at 8:00 AM which is 2 in second row and so on for all values of column Tushar and Lohit respectively.我手动创建了“值差异”列,计算是上午 8:15 的值 - 上午 8:00 的值,第二行中的值为 2,依此类推,分别用于 Tushar 和 Lohit 列的所有值。 How can i do this calculation in Spotfire i believe over and previous function can help but i am unable find anything on this.我如何在 Spotfire 中进行此计算,我相信之前的 function 可以提供帮助,但我无法找到任何相关信息。 Please help请帮忙

Name    Time    Values  Difference in values
Tushar  08:00 AM    2   0
Tushar  08:15 AM    4   2
Tushar  08:30 AM    5   1
Tushar  08:45 AM    6   1
Tushar  09:00 AM    7   1
Lohit   08:00 AM    2   0
Lohit   08:15 AM    4   2
Lohit   08:30 AM    5   1
Lohit   08:45 AM    6   1

This should work这应该工作

SN([Values] - Max([Values]) over (Intersect(Previous([Time]),[Name])),0)

where Max(..) is just to have an aggregation, since it is only looking at the previous Time row for each value of Name.其中 Max(..) 只是为了进行聚合,因为它只查看 Name 的每个值的前一个 Time 行。 [so Min would work just as well]. [所以 Min 也可以正常工作]。

SN(...) is there to set the result to 0 when it is empty (as in the first row of each Name). SN(...) 用于将结果设置为 0 当它为空时(如每个名称的第一行)。

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

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