在spotfire中需要提取特定季度的员工姓名,添加和离开的人数。
像我们一样Employee_nm Quarter Mohan 1 Rohan 1 Sohan 1 Mohan 2 Rohan 2 Joseph 2
输出: - 当我们选择第二季度结果时
Left Add Sohan joseph
答案 0 :(得分:0)
IronPython脚本可以通过设置感兴趣的季度的属性控件来执行此操作。
用户从下拉菜单中选择数字1-4,该菜单存储在文档属性“lstQuarter”中并连接到执行计算的脚本。
用于计算的伪代码:
Access the table Fill listA with all the names from lstQuarter - 1 Fill listB with all the names from lstQuarter Iterate through the lists comparing each name. Those in listA but not listB have been removed, those in listB but not listA have been added. Write this information into a string, out to excel, wherever you want it.
如果您想使用此信息更新Spotfire中的表,您需要先将其写入Excel,然后用它替换数据表,但这些都可以编写脚本。
答案 1 :(得分:0)
此问题有一个解决方案,只需要一个属性控件,并将2个计算值设置为文本区域加上2个计算列。
首先,我将数据集扩展为显示全年:
Employee_nm Quarter
Mohan 1
Rohan 1
Sohan 1
Mohan 2
Rohan 2
Joseph 2
Mohan 3
Joseph 3
Katelyn 3
Katelyn 4
Joseph 4
Wesley 4
接下来,计算列:
Case First([Quarter]) OVER ([Employee_nm])
when 1 then "Q1"
when 2 then "Q2"
when 3 then "Q3"
when 4 then "Q4"
end as [added]
- 和 -
if(Last([Quarter]) OVER ([Employee_nm])!=Max([Quarter]),
Case Last([Quarter]) OVER ([Employee_nm])
when 1 then "Q2"
when 2 then "Q3"
when 3 then "Q4"
when 4 then "Q1 Following Year"
end,"") as [left]
注意:以上内容仅适用于给定的数据集,但可以轻松扩展以适应多年。
最后,计算出的值:
UniqueConcatenate(if([added]='${Quarter}',Concatenate([Employee_nm]," added ",[added]),""))
- 和 -
UniqueConcatenate(if([Left]='${Quarter}',Concatenate([Employee_nm]," left ",[Left]),""))
注意:由于'UniqueConcatenate()'函数,上述值在很多情况下会显示一个前导逗号。这些可以使用计算值中的文本函数来处理,并且为了便于阅读,该逻辑已被排除在此答案之外。
我希望这会有所帮助。
答案 2 :(得分:0)
您可以插入计算列以标识每季度添加/删除的员工:
Concatenate(If(Find([Employee_nm],Concatenate([Employee_nm]) OVER
(Previous([Quarter])))=0,"Added in this Quarter"),If(Find([Employee_nm],
Concatenate([Employee_nm]) OVER (Next([Quarter])))=0,"Removed from Next
Quarter"))
您可以通过过滤季度列来查看每季度的结果。