An XPR Series is written and read like a normal Series with the following exceptions:
- one of the fields is
xpr
, which is an object containing the following sub-keys: - expression (required) - the Expressions to execute when retrieving points
- g (optional) - the Init Expression per the Expressions documentation
- linked_fields (optional) - list of fields to link to the upstream series
- the points are read-only
- when points are requested, they are evaluated using the Expressions stored in the xpr.expression field
Applying operators to XPR Series results
Operators can be applied to XPR Series, just like any other series. For example we may have a XPR Series identified by Series ID My\Xpr\Series with expression:
={{sid=My\Favorite\Series}}*2
We can then fetch points from that XPR Series and apply an operator using a query like this:
sid=My\Xpr\Series@A:h
Note that operators applied onto a XPR series like the above are executed on top of the result of the XPR series. First, the result of XPR series is calculated. Then, after the result is retrieved, the hourly average is calculated. This will typically yield the same result as putting the operator onto the end of the expression itself, like so:
={{sid=My\Favorite\Series}}*2@A:h
This is not always the case. Applying an asof operator to the underlying expression like so:
={{sid=My\Favorite\Series}}*2@asof:-2d
retrieves My\Favorite\Series as of 2 days ago and returns those points multiplied by two. However, applying asof to the XPR Series like so:
sid=My\Xpr\Series@asof:-2d
retrieves the XPR Series itself as it looked two days ago and not the underlying series in the expression. If the expression had not changed, the result would be the exact same with and without the asof operator. If the XPR Series was created an hour ago, the result would be empty because two days ago there was no XPR Series at all.