sporfire:计算每15分钟的平均值

时间:2016-09-05 14:58:49

标签: average spotfire

我是Spotfire的初学者。我对计算列每15分钟的平均计算有疑问。样本表可以是这样的:

id  time-stamp              value
 1  7/1/2016 12:01:01 AM    1.1
 2  7/1/2016 12:05:03 AM    0.9
 3  7/1/2016 12:08:04 AM    1.2
 4  7/1/2016 12:09:06 AM    0.8
 5  7/1/2016 12:12:09 AM    0.4
 6  7/1/2016 12:14:10 AM    0.6
 7  7/1/2016 12:15:12 AM    1.3
 8  7/1/2016 12:18:04 AM    1.4
 9  7/1/2016 12:21:06 AM    0.7
 10 7/1/2016 12:24:09 AM    1.7
 11 7/1/2016 12:31:10 AM    0.5
 12 7/1/2016 12:39:12 AM    1.3

我想计算每15分钟的平均值,该表已按时间排序 我想要的决赛桌是:

 time-stamp               Avg
 7/1/2016 12:00:00 AM    0.83333
 7/1/2016 12:15:00 AM    1.275
 7/1/2016 12:30:00 AM    0.9

例如,第一个数字为0.83333 =(1.1 + 0.9 + 1.2 + 0.8 + 0.4 + 0.6)/ 6

似乎我应该确定一个新表的计算表达式,但是如何计算平均值。每15分钟一次。有人可以帮帮我吗?

感谢您的帮助:)

注意:感谢代码@ ksp585,但在此之后,我仍然遇到一个小问题,交叉表只显示时间戳到晚上9:45

enter image description here

1 个答案:

答案 0 :(得分:2)

@ ZAWD - 我创建了一个计算列,将时间戳分为4个小时,持续一个小时。在下面的交叉表中使用此列来计算平均时间。

时间戳分组表达式(time_interval):

case  
when (DatePart("minute",[time-stamp])>0) and (DatePart("minute",[time-stamp])<15) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":00" & ":00" 
when (DatePart("minute",[time-stamp])=15) and (DatePart("second",[time-stamp])>0) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":15" & ":00" 
when (DatePart("minute",[time-stamp])>15) and (DatePart("minute",[time-stamp])<30) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":15" & ":00" 
when (DatePart("minute",[time-stamp])=30) and (DatePart("second",[time-stamp])>0) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":30" & ":00" 
when (DatePart("minute",[time-stamp])>30) and (DatePart("minute",[time-stamp])<45) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":30" & ":00" 
when (DatePart("minute",[time-stamp])=45) and (DatePart("second",[time-stamp])>0) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":45" & ":00" 
when (DatePart("minute",[time-stamp])>45) and (DatePart("minute",[time-stamp])<=60) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":45" & ":00" 
when (DatePart("minute",[time-stamp])=0) and (DatePart("second",[time-stamp])>0) then Date([time-stamp]) & " " & Hour([time-stamp]) & ":00" & ":00"
else null end

决赛桌:

enter image description here

使用不同的日期时间格式进行测试: enter image description here