Can I make a new "Treatment" to make timeseries data through a metric

#1

Say I have a set of timeseries data which is attached to a specific version number, each version of the set of data is then updated on a monthly basis. So,

V1: Jan Feb Mar April May etc
V2: Feb Mar April May etc
V3: Mar April May etc

Now say I want a metric and I want it to show the following timeseries data:

V1_Jan V2_Feb V3_Mar V3_April V3_May etc

What I originally thought you could do was use the following inside the tsDecl in the simple metric
tsDecl: {
data: “ChosenFiled”,
value: “ChosenDataPoint.value”,
treatment: “PREVIOUS”,
start: “ChosenStartDate”,
}

However, when using this what you get instead of the required set above is:

V1_Jan avg(V1_Feb+V2_Feb) avg(V1_Mar+V2_Mar+V3_Mar) etc

So while creating the series it will average out the months which sit in the same date range.

Can I create a treatment that will take the previous value, but when presented with multiple records only gives the most recent version of the months data?

#2

If the time series data is stored in a TimedDataPoint or TimeseriesDataPoint type, you can utilize the dataVersion field.

During the normalization process, data with the highest dataVersion will be used.

For example, suppose you have the following types:

entity type Building {
expectedElectricityConcumpstionSeries: ExpectedElectricityConcumpstionSeries
}

entity type ExpectedElectricityConcumpstionSeries mixes TimedDataHeader

entity type ExpectedElectricityConcumpstionMeasurement mixes TimedDataPoint< ExpectedElectricityConcumpstionSeries > {
consumption: int
}

The time series data is saved into ExpectedElectricityConcumpstionMeasurement type.
Suppose below is the data you have for ExpectedElectricityConcumpstionMeasurement:

[{
start: “2017-01-01”,
dataVersion: 1,
consumption: 2
},
{
start: “2017-02-01”,
dataVersion: 1,
consumption: 3
},
{
start: “2017-02-01”,
dataVersion: 2,
consumption: 5
}]

Note: start and dataVersion are defined in TimedDataPoint type.

You can define your metric as
{
“id”: “ExpectedConsumption_Building”,
“name”: “ExpectedConsumption”,
“path”: “expectedElectricityConcumpstionSeries”,
“expression”: “sum(sum(normalized.data.consumption))”
}

The metric will return 2 for the January 2017 and 5 for for February 2017 because the value of 5 has a higher dataVersion than the value of 3.

1 Like