Spotfire - 多年来的 ID 差异
Spotfire - Difference of IDs over years
我有一个这样的数据集:一个 3 年的员工列表,其中一些员工在所有三年中都存在 (ID:1,2,3),一些 joined/left 公司在不同年份。
Year IDEmployee
2014 1
2014 2
2014 3
2014 4
2015 1
2015 2
2015 3
2015 5
2015 6
2016 1
2016 2
2016 3
2016 6
2016 7
2016 8
我需要计算所有时期的 in/out 通量(2015 年与 2014 年和 2016 年与 2015 年)
- "In" flux = N+1 年的员工人数,N 年不存在
- "Out" flux = N年员工人数,N+1年不在场
在这种情况下,结果是:
- 2015 年 - 变化中:2(ID:5,6,上一年不存在)。 Out flux: 1 (ID:4 前一年存在但现在不存在)
- 对于 2016 年 - 不断变化:2(ID:7,8,上一年不存在)。 Out flux: 1 (ID:5 前一年存在但现在不存在)
最简单的方法应该是使用计算列,但我不会写:
InFlux column: UniqueCount([IDEmployee]) OVER ([Year]) - UniqueCount([IDEmployee]) OVER (PreviousPeriod([Year]))
OutFlux column: UniqueCount([IDEmployee]) OVER ([Year]) - UniqueCount([IDEmployee]) OVER (NextPeriod([Year]))
有什么建议吗?
非常感谢,
洛隆
@Lollone- 请检查以下解决方案,让我知道它是否适用于所有可能的情况。
流动列:
If(Count([ID]) over (intersect(previousperiod([Year]),[ID]))=0,"In")
流出栏:
If(([Year]!=Max([Year])) and (Count([ID]) over (intersect(nextperiod([Year]),[ID]))=0),"Out")
最终输出:
我有一个这样的数据集:一个 3 年的员工列表,其中一些员工在所有三年中都存在 (ID:1,2,3),一些 joined/left 公司在不同年份。
Year IDEmployee
2014 1
2014 2
2014 3
2014 4
2015 1
2015 2
2015 3
2015 5
2015 6
2016 1
2016 2
2016 3
2016 6
2016 7
2016 8
我需要计算所有时期的 in/out 通量(2015 年与 2014 年和 2016 年与 2015 年)
- "In" flux = N+1 年的员工人数,N 年不存在
- "Out" flux = N年员工人数,N+1年不在场
在这种情况下,结果是:
- 2015 年 - 变化中:2(ID:5,6,上一年不存在)。 Out flux: 1 (ID:4 前一年存在但现在不存在)
- 对于 2016 年 - 不断变化:2(ID:7,8,上一年不存在)。 Out flux: 1 (ID:5 前一年存在但现在不存在)
最简单的方法应该是使用计算列,但我不会写:
InFlux column: UniqueCount([IDEmployee]) OVER ([Year]) - UniqueCount([IDEmployee]) OVER (PreviousPeriod([Year]))
OutFlux column: UniqueCount([IDEmployee]) OVER ([Year]) - UniqueCount([IDEmployee]) OVER (NextPeriod([Year]))
有什么建议吗?
非常感谢,
洛隆
@Lollone- 请检查以下解决方案,让我知道它是否适用于所有可能的情况。
流动列:
If(Count([ID]) over (intersect(previousperiod([Year]),[ID]))=0,"In")
流出栏:
If(([Year]!=Max([Year])) and (Count([ID]) over (intersect(nextperiod([Year]),[ID]))=0),"Out")
最终输出: