Spotfire 如何沿一列进行计算
Spotfire how to make calculation along one coloumn
我有一个数据 table,因为 below.I 想创建一个名为 "Time Difference" 的新列,它捕获 [STAGE] 开始和 [STAGE] 结束之间的时间差。有没有不用数据转换的方法呢?
谢谢!
假设每个 ID
都是唯一的,并且您的数据按 Time
排序,其中 Stage = Start
是每个 ID
的第一行,Stage = End
是每个ID
的最后一行,你可以使用这个:
Concatenate(Min([Time]) OVER ([ID]),"-",Max([Time]) over ([ID]))
结果
+----+---------+---------+------+-----------------+
| ID | Stage | Action | Time | Time Difference |
+----+---------+---------+------+-----------------+
| 1 | Start | approve | A | A-F |
| 1 | Process | approve | B | A-F |
| 1 | Process | approve | C | A-F |
| 1 | Process | approve | D | A-F |
| 1 | Process | decline | E | A-F |
| 1 | End | approve | F | A-F |
| 2 | Start | approve | G | G-I |
| 2 | Process | decline | H | G-I |
| 2 | End | approve | I | G-I |
+----+---------+---------+------+-----------------+
如果您的数据尚未排序,您可以应用 Rank()
来解决此问题。如果是这样,请告诉我。
EDIT WITH NEW DATA
表达式
Concatenate(Min(If((Upper([Stage])="START") and (Upper([Action])="APPROVE"),Max([Time]) OVER ([ID]))) OVER ([ID]),"-",Min(If((Upper([Stage])="END") and (Upper([Action])="APPROVE"),Max([Time]) OVER ([ID]))) OVER ([ID]))
简化
Concatenate(Min(If((Upper([Stage])="START") and (Upper([Action])="APPROVE"),[Time])) OVER ([ID]),"-",Min(If((Upper([Stage])="END") and (Upper([Action])="APPROVE"),[Time])) OVER ([ID]))
结果
+----+---------+---------+------+-----------------+
| ID | Stage | Action | Time | Time Difference |
+----+---------+---------+------+-----------------+
| 1 | On hold | decline | A | C-H |
| 1 | Start | decline | B | C-H |
| 1 | Start | approve | C | C-H |
| 1 | Process | DECLINE | D | C-H |
| 1 | Process | approve | E | C-H |
| 1 | Process | approve | F | C-H |
| 1 | End | decline | G | C-H |
| 1 | End | approve | H | C-H |
| 2 | Start | approve | I | I-K |
| 2 | Process | decline | J | I-K |
| 2 | End | approve | K | I-K |
+----+---------+---------+------+-----------------+
我有一个数据 table,因为 below.I 想创建一个名为 "Time Difference" 的新列,它捕获 [STAGE] 开始和 [STAGE] 结束之间的时间差。有没有不用数据转换的方法呢?
谢谢!
假设每个 ID
都是唯一的,并且您的数据按 Time
排序,其中 Stage = Start
是每个 ID
的第一行,Stage = End
是每个ID
的最后一行,你可以使用这个:
Concatenate(Min([Time]) OVER ([ID]),"-",Max([Time]) over ([ID]))
结果
+----+---------+---------+------+-----------------+
| ID | Stage | Action | Time | Time Difference |
+----+---------+---------+------+-----------------+
| 1 | Start | approve | A | A-F |
| 1 | Process | approve | B | A-F |
| 1 | Process | approve | C | A-F |
| 1 | Process | approve | D | A-F |
| 1 | Process | decline | E | A-F |
| 1 | End | approve | F | A-F |
| 2 | Start | approve | G | G-I |
| 2 | Process | decline | H | G-I |
| 2 | End | approve | I | G-I |
+----+---------+---------+------+-----------------+
如果您的数据尚未排序,您可以应用 Rank()
来解决此问题。如果是这样,请告诉我。
EDIT WITH NEW DATA
表达式
Concatenate(Min(If((Upper([Stage])="START") and (Upper([Action])="APPROVE"),Max([Time]) OVER ([ID]))) OVER ([ID]),"-",Min(If((Upper([Stage])="END") and (Upper([Action])="APPROVE"),Max([Time]) OVER ([ID]))) OVER ([ID]))
简化
Concatenate(Min(If((Upper([Stage])="START") and (Upper([Action])="APPROVE"),[Time])) OVER ([ID]),"-",Min(If((Upper([Stage])="END") and (Upper([Action])="APPROVE"),[Time])) OVER ([ID]))
结果
+----+---------+---------+------+-----------------+
| ID | Stage | Action | Time | Time Difference |
+----+---------+---------+------+-----------------+
| 1 | On hold | decline | A | C-H |
| 1 | Start | decline | B | C-H |
| 1 | Start | approve | C | C-H |
| 1 | Process | DECLINE | D | C-H |
| 1 | Process | approve | E | C-H |
| 1 | Process | approve | F | C-H |
| 1 | End | decline | G | C-H |
| 1 | End | approve | H | C-H |
| 2 | Start | approve | I | I-K |
| 2 | Process | decline | J | I-K |
| 2 | End | approve | K | I-K |
+----+---------+---------+------+-----------------+