spotfire-如何找到创建一个列来计算下一阶段的时间
spotfire- how to find create a column to calculate the time of next stage
我想创建一个计算列来显示按 [案例 ID]、[阶段] 和 [操作] 分组的操作结束时间。舞台的顺序不必按字母顺序排列,可以重复。说在[stage]'C'之后,我们以后可以再[stage]'c'
谢谢,
感谢更新测试数据。询问时,数据类型极其重要。此外,测试数据应尽可能接近实际数据,否则解决方案通常无法扩展。例如,在测试数据中,值只是时间。按时排序不考虑日期,因此都一视同仁。由于这些值实际上是 DateTime,因此我已将其添加到测试数据中。这些表达式将为您提供问题中确定的预期结果。
Rank([Time_Action_Begin],"asc",[Case ID]) as [Rank]
Min([Time_Action_Begin]) OVER (Intersect([Case ID],Next([Rank])))
结果
+---------+-------+----------+------------------------+------------------------+------+
| Case ID | Stage | Action | Time_Action_Begin | Time_Action_End | Rank |
+---------+-------+----------+------------------------+------------------------+------+
| 1 | A | approve | 01/01/2016 11:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 1 | A | approve | 01/01/2016 11:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 1 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 1:30:00 AM | 3 |
| 1 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 1:30:00 AM | 3 |
| 1 | C | approve | 01/02/2016 1:30:00 AM | 01/02/2016 2:30:00 AM | 5 |
| 1 | C | approve | 01/02/2016 1:30:00 AM | 01/02/2016 2:30:00 AM | 5 |
| 1 | D | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 7 |
| 1 | D | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 7 |
| 1 | E | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 9 |
| 1 | E | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 9 |
| 1 | F | complete | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 11 |
| 1 | F | complete | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 11 |
| 1 | C | approve | 01/02/2016 5:30:00 AM | | 13 |
| 1 | C | approve | 01/02/2016 5:30:00 AM | | 13 |
| 2 | A | approve | 01/01/2016 10:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 2 | A | approve | 01/01/2016 10:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 2 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 2:30:00 AM | 3 |
| 2 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 2:30:00 AM | 3 |
| 2 | C | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 5 |
| 2 | C | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 5 |
| 2 | D | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 7 |
| 2 | D | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 7 |
| 2 | E | approve | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 9 |
| 2 | E | approve | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 9 |
| 2 | F | complete | 01/02/2016 5:30:00 AM | 01/02/2016 6:30:00 AM | 11 |
| 2 | F | complete | 01/02/2016 5:30:00 AM | 01/02/2016 6:30:00 AM | 11 |
| 2 | C | approve | 01/02/2016 6:30:00 AM | | 13 |
| 2 | C | approve | 01/02/2016 6:30:00 AM | | 13 |
+---------+-------+----------+------------------------+------------------------+------+
我想创建一个计算列来显示按 [案例 ID]、[阶段] 和 [操作] 分组的操作结束时间。舞台的顺序不必按字母顺序排列,可以重复。说在[stage]'C'之后,我们以后可以再[stage]'c'
谢谢,
感谢更新测试数据。询问时,数据类型极其重要。此外,测试数据应尽可能接近实际数据,否则解决方案通常无法扩展。例如,在测试数据中,值只是时间。按时排序不考虑日期,因此都一视同仁。由于这些值实际上是 DateTime,因此我已将其添加到测试数据中。这些表达式将为您提供问题中确定的预期结果。
Rank([Time_Action_Begin],"asc",[Case ID]) as [Rank]
Min([Time_Action_Begin]) OVER (Intersect([Case ID],Next([Rank])))
结果
+---------+-------+----------+------------------------+------------------------+------+
| Case ID | Stage | Action | Time_Action_Begin | Time_Action_End | Rank |
+---------+-------+----------+------------------------+------------------------+------+
| 1 | A | approve | 01/01/2016 11:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 1 | A | approve | 01/01/2016 11:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 1 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 1:30:00 AM | 3 |
| 1 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 1:30:00 AM | 3 |
| 1 | C | approve | 01/02/2016 1:30:00 AM | 01/02/2016 2:30:00 AM | 5 |
| 1 | C | approve | 01/02/2016 1:30:00 AM | 01/02/2016 2:30:00 AM | 5 |
| 1 | D | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 7 |
| 1 | D | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 7 |
| 1 | E | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 9 |
| 1 | E | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 9 |
| 1 | F | complete | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 11 |
| 1 | F | complete | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 11 |
| 1 | C | approve | 01/02/2016 5:30:00 AM | | 13 |
| 1 | C | approve | 01/02/2016 5:30:00 AM | | 13 |
| 2 | A | approve | 01/01/2016 10:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 2 | A | approve | 01/01/2016 10:30:00 PM | 01/02/2016 12:30:00 AM | 1 |
| 2 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 2:30:00 AM | 3 |
| 2 | B | approve | 01/02/2016 12:30:00 AM | 01/02/2016 2:30:00 AM | 3 |
| 2 | C | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 5 |
| 2 | C | approve | 01/02/2016 2:30:00 AM | 01/02/2016 3:30:00 AM | 5 |
| 2 | D | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 7 |
| 2 | D | approve | 01/02/2016 3:30:00 AM | 01/02/2016 4:30:00 AM | 7 |
| 2 | E | approve | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 9 |
| 2 | E | approve | 01/02/2016 4:30:00 AM | 01/02/2016 5:30:00 AM | 9 |
| 2 | F | complete | 01/02/2016 5:30:00 AM | 01/02/2016 6:30:00 AM | 11 |
| 2 | F | complete | 01/02/2016 5:30:00 AM | 01/02/2016 6:30:00 AM | 11 |
| 2 | C | approve | 01/02/2016 6:30:00 AM | | 13 |
| 2 | C | approve | 01/02/2016 6:30:00 AM | | 13 |
+---------+-------+----------+------------------------+------------------------+------+