Create metric getting measurement with the latest dataVersion

How can I create a metric that, rather than applying a treatment to a collection of measurement I have on the same timestamp, will only get the measurement with the latest dataVersion?

As long as the dataVersion field is set in the TSDecl metric, this behavior will be applied. You will still have to provide a treatment in cases where there will be two points with the same data version. You can choose to provide the treatment as LATEST

I don’t know what dataVersion will be the latest one. Let’s assume that I add more and more predictions on a timestamp and I always want to show the latest prediction in my metric. Can I do that?

If you always want to show the latest prediction and are consistently generating predictions from the C3 platform, you can set the dataVersion of each prediction to be DateTime.now().valueOf(). This will ensure the most recently generated prediction has the greatest value for dataVersion and thus will be used as the value in your TsDecl metric

An if I access it through expression like that does it have the same behavior (taking the latest dataVersion) as in tsDecl?

{
    "id": "PredictedMeteredElectricityConsumption_ServicePoint",
    "name": "PredictedMeteredElectricityConsumption",
    "description": "Metered electricity consumption estimated by an ML model.",
    "srcType": "ServicePoint",
    "path": "measurements.(name == 'predictedMeteredElectricityConsumption')",
    "expression": "avg(avg(normalized.data.quantity))"
}

@rohit.sureka can correct me if I am wrong here but my understanding is that the Normalization engine will indeed use dataVersion to find the best data point for each interval at which a Timeseries is normalized. So yes, that should be the same as if you were to use the dataVersion field in a TsDecl metric