【发布时间】:2017-08-13 17:52:50
【问题描述】:
【问题讨论】:
-
每个ID可以只有1个开始和1个结束吗?
-
是的,你是对的
标签: calculated-columns spotfire
【问题讨论】:
标签: calculated-columns spotfire
假设每个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() 即可解决此问题。如果是这样,请告诉我。
使用新数据编辑
表达式
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 |
+----+---------+---------+------+-----------------+
【讨论】: