How does tsDecl dataVersion work?


#1

I have a type that mixes ‘TimedValueHistory’ and I am trying to write a simple metric that will take the latest TimedValueHistory for instances that have the same parent and timestamp.

“tsDecl” : {
“data” : “(Type that mixes TimedValueHistory)”,
“dataVersion” : “toMillis((Type that mixes TimedValueHistory).meta.created)”,
“treatment” : “AVG”,
“start” : “timestamp”,
“value” : “value”
}

I am getting the average of the values, instead of the latest DataVersion.


#2

Once you have specified the path for “data”, the other fields are relative to “data”, including “dataVersion”.
The correct way is:
“tsDecl” : {
“data” : “(Type that mixes TimedValueHistory)”,
“dataVersion” : “toMillis(meta.created)”,
“treatment” : “AVG”,
“start” : “timestamp”,
“value” : “value”
}

Currently due to a platform bug, the current correct solution is:
“tsDecl” : {
“data” : “(Type that mixes TimedValueHistory)”,
“dataVersion” : “round(toMillis(meta.created))”,
“treatment” : “AVG”,
“start” : “timestamp”,
“value” : “value”
}