Spotfire计算列:时间差OVER列值

时间:2017-07-13 10:25:01

标签: calculated-columns spotfire

民间,

我有一个数据表:

My data table

我正在努力实现重复计算并且无法这样做。

我已设法将每个主代码作为计算列进行操作,并尝试将所有计算出的时间差实现为单个计算列,如上图所示。

任何帮助表示赞赏!

感谢。

PS:数据跨越范围(1-200天等),并且从一行到另一行的差异为5秒,主代码可能发生变化。我试图获得每次迭代的每个代码的周期。

希望我很清楚。

1 个答案:

答案 0 :(得分:0)

  

以下是您需要采取的步骤

  • 在下面插入计算的第1列,并将其命名为ROWID
  • 在下面插入计算的第2列,并将其命名为DateTime
  • 在下面插入计算的第3列,并将其命名为Grouping
  • 在下面插入计算的第4列,并将其命名为DateDifference

表达式1

RowId()

表达式2

DateTime(Concatenate([Date]," ",[Time]))

表达3

Min(If(([Master code]<>Max([Master code]) over (Next([ROWID]))) or ([ROWID]=Max([ROWID])),[ROWID] - Min([ROWID]) over (AllPrevious([ROWID])))) OVER (AllNext([ROWID]))

表达式4

Abs(DateDiff(Min([DateTime]) OVER (Intersect([Grouping],AllPrevious([ROWID]))),[DateTime]))
  

如果您真的只想填充上面列出的行,那么   从这里继续......

  • 插入已计算的第5列并将其命名为RowsToKeep

表达式5

If(([Master code]<>Max([Master code]) over (Next([ROWID]))) or ([ROWID]=Max([ROWID])),[DateDifference])

<强>结果

+-------+------------+-------------+------------------+-------------+----------+----------------+------------+
| ROWID |    Date    |    Time     |     DateTime     | Master code | Grouping | DateDifference | RowsToKeep |
+-------+------------+-------------+------------------+-------------+----------+----------------+------------+
|     1 | 12/07/2017 | 1:05:40 AM  | 12/07/2017 1:05  |         100 |        0 | 0:00:00        |            |
|     2 | 12/07/2017 | 4:45:20 AM  | 12/07/2017 4:45  |         100 |        0 | 3:39:40        |            |
|     3 | 12/07/2017 | 6:20:10 AM  | 12/07/2017 6:20  |         100 |        0 | 5:14:30        | 5:14:30    |
|     4 | 12/07/2017 | 6:20:11 AM  | 12/07/2017 6:20  |         400 |        4 | 0:00:00        |            |
|     5 | 12/07/2017 | 8:15:12 AM  | 12/07/2017 8:15  |         400 |        4 | 1:55:01        |            |
|     6 | 12/07/2017 | 9:12:10 AM  | 12/07/2017 9:12  |         400 |        4 | 2:51:59        |            |
|     7 | 12/07/2017 | 9:45:45 AM  | 12/07/2017 9:45  |         400 |        4 | 3:25:34        | 3:25:34    |
|     8 | 12/07/2017 | 9:45:46 AM  | 12/07/2017 9:45  |         120 |        6 | 0:00:00        |            |
|     9 | 12/07/2017 | 10:20:35 AM | 12/07/2017 10:20 |         120 |        6 | 0:34:49        | 0:34:49    |
|    10 | 12/07/2017 | 10:20:36 AM | 12/07/2017 10:20 |         100 |       10 | 0:00:00        |            |
|    11 | 12/07/2017 | 10:25:45 AM | 12/07/2017 10:25 |         100 |       10 | 0:05:09        |            |
|    12 | 12/07/2017 | 11:15:55 AM | 12/07/2017 11:15 |         100 |       10 | 0:55:19        |            |
|    13 | 12/07/2017 | 12:22:22 PM | 12/07/2017 12:22 |         100 |       10 | 2:01:46        | 2:01:46    |
|    14 | 12/07/2017 | 12:22:23 PM | 12/07/2017 12:22 |         350 |       16 | 0:00:00        |            |
|    15 | 12/07/2017 | 3:35:40 PM  | 12/07/2017 15:35 |         350 |       16 | 3:13:17        |            |
|    16 | 12/07/2017 | 3:42:25 PM  | 12/07/2017 15:42 |         350 |       16 | 3:20:02        |            |
|    17 | 12/07/2017 | 4:38:17 PM  | 12/07/2017 16:38 |         350 |       16 | 4:15:54        |            |
|    18 | 12/07/2017 | 4:52:35 PM  | 12/07/2017 16:52 |         350 |       16 | 4:30:12        |            |
|    19 | 12/07/2017 | 4:52:40 PM  | 12/07/2017 16:52 |         350 |       16 | 4:30:17        | 4:30:17    |
|    20 | 12/07/2017 | 4:52:41 PM  | 12/07/2017 16:52 |         100 |       19 | 0:00:00        |            |
|    21 | 12/07/2017 | 7:23:23 PM  | 12/07/2017 19:23 |         100 |       19 | 2:30:42        |            |
|    22 | 12/07/2017 | 8:23:20 PM  | 12/07/2017 20:23 |         100 |       19 | 3:30:39        | 3:30:39    |
+-------+------------+-------------+------------------+-------------+----------+----------------+------------+