How do I apply one timeseries as the missing values of another timeseries?


#1

I have two metrics: MyMetric and MyMetricIsMissing. How do I write a CompoundMetric expression that applies MyMetricIsMissing as the missing values of MyMetric?

Example:

MyMetric => {
 data: [1, 2, 3, 4, 5],
 missing: [0, 0, 0, 0, 0]
}
MyMetricIsMissing => {
  data: [100, 50, 0, 50, 100],
  missing: [0, 0, 0, 0, 0]
}

HypotheticalCompoundMetric => {
  data: [1, 2, 3, 4, 5],
  missing: [100, 50, 0, 50, 100]
}

Is there a function I can use to do this? Or will I have to write my own MetricFunctionLibrary mixin?


#2

expression: “missing(MyMetric) < 0.1 ? MyMetric : MyMetricIsMissing”

This will use MyMetric when MyMetric is AT LEAST 90% available (less than 10% missing) otherwise it will use MyMetricIsMissing

The ternary operator is applied timeslice by timeslice


#3

That solution manipulates the data of the resulting timeseries, not its missing values


#4

In the meantime, have you found a solution? A MetricFunctionLibrary function perhaps?


#5

did you try with expression engine function fillMissing?


#6

The doc says “the resultant timeseries is fully available,” which means the missing are all 0s instead of MyMetricMissing.data().


#7

@AlexBakic yes you can use MetricFunctionLibrary for this


#8

Why not use a metric expression like: missing() > 0.5 ? expr1 : expr2 in your metric?


#9

He wants to set missing (metadata), not data, if I understand correctly.