简体   繁体   中英

Spotfire - Downsample Time Series Data - Calculate New Column

In Tibco Spotfire, how do I downsample time series data to 30 minute intervals and take the closest value to the 00 and 30 minute timestamps?

ID  DateTime            Value
-----------------------------
ID1 2022-06-06 19:01:34Z 100
ID1 2022-06-06 19:06:31Z 200
ID1 2022-06-06 19:11:34Z 300
ID1 2022-06-06 19:16:31Z 400
ID1 2022-06-06 19:21:32Z 500
ID1 2022-06-06 19:26:33Z 600
ID1 2022-06-06 19:31:32Z 700

Desired Spotfire table

ID  DateTime            Value
-----------------------------
ID1 2022-06-06 19:00:00Z 100
ID1 2022-06-06 19:30:00Z 700

Maybe not with a single calculated column, but this should help.

1 - create a timestamp: [TimeStamp] as ToEpochSeconds([DateTime])

2 - create a timestamp to the nearest half-hour: [RoundTimeStamp] as Round([TimeStamp] / 1800,0) * 1800

3 - turn it back into a datetime: [RoundDateTime]: FromEpochSeconds(Integer([RoundTimeStamp]))

4 - select the value: [ValueForRoundDateTime] as ValueforMin(Abs([TimeStamp] - [RoundTimeStamp]),[Value]) over (Intersect([ID],[RoundTimeStamp]))

This gives you the columns you wanted, [RoundDateTime] and [ValueForRoundDateTime].

To create a table with only the necessary rows, you could add another table based on the current one:

select + then choose Other then Linked copy to data table in analysis.

Then go to the Data Canvas, add transformations:

1 - exclude all columns but [ID], RoundDateTime] and [ValueForRoundDateTime]

2 - filter as Rank(baserowid(),"asc",Concatenate([RoundDateTime],[ID]))=1

(the latter from this support article: https://support.tibco.com/s/article/Tibco-KnowledgeArticle-Article-42284 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM