Latest value measurement

#1

We have a requirement to display sensor with the latest measured value on a map.
The type used is BasePhysicalMeasurementSeries.

I tryed with the evaluate method, but no succes.
How can I get the timestamp and value of the latest measurement?

0 Likes

#2

We succeded with this code:

PointMeasurement.fetch({
  filter:'parent.id == "OurId"',
  order:'descending(start)',
  limit:1,
});

Now working on a way to group by, so in one request multiple latest values…

0 Likes

#3

We also hold this information while normalizing the time series and you can get the latest value and latest date of a particular ts field by using the following expressions:

  1. latestValue(normalized.data.tsFieldName) - returns latest value
  2. latest(normalized.data.tsFieldName) - returns latest date

similarly there is earliestValue and earliest functions available too. This operation is much quicker than doing a sort on all the measurement objects

1 Like