Using same binding variable in multiple metrics

We have many metrics where we want to use the same variable across these metrics. For example, PowerFactor is a CompoundMetric referencing SimpleMetrics ConsumptionActive and ConsumptionReactive. We want to pass in the same variable value to both ConsumptionActive and ConsumptionReactive through the binding in the PowerFactor evalMetrics call (see section below the page divider for the metric definitions and evalMetrics call)

However, when we make the PowerFactor evalMetrics call and pass in the binding we get the error:

"The variable name 'reference' occurs multiple times in different compound metrics. This is currently not supported. You can temporarily change the variable name"

Is this in the roadmap or do we have to define a different variable for each metric and pass the value to each of them in the EvalMetricsSpec as below?

  • ConsumptionActive:
    "variables"   :
    [
      {"name" : "referenceDateActive","dataType" : "string","description" : "datetime parameter"}
    ]
    
  • ConsumptionReactive:
    "variables"   :
    [
      {"name" : "referenceDateReactive","dataType" : "string","description" : "datetime parameter"}
    ]
    
  • evalMetrics:
    ServicePoint.evalMetrics({
    "ids" : [ "1911846" ],
    "expressions" : [ "PowerFactor" ],
    "interval" : "MONTH",
    "start" : "2006-08-01T00:00:00",
    "end" : "2019-10-01T00:00:00",
    "bindings" : {
        "referenceDateActive" : "2010-01-01",
        "referenceDateReactive" : "2010-01-01"
    }
    });
    

EvalMetrics call:

ServicePoint.evalMetrics({
  "ids" : [ "1911846" ],
  "expressions" : [ "PowerFactor" ],
  "interval" : "MONTH",
  "start" : "2006-08-01T00:00:00",
  "end" : "2019-10-01T00:00:00",
  "bindings" : {
    "referenceDate" : "2010-01-01"
  }
});

PowerFactor (Compound):

{
  "id" : "PowerFactor",
    "name" : "PowerFactor",
    "expression":"((ConsumptionActive > 0) || (ConsumptionReactive > 0)) ? ConsumptionActive / sqrt(pow(ConsumptionActive, 2) + pow(ConsumptionReactive, 2)) : 1",
    "description" : "PowerFactor"
}

ConsumptionActive (Simple):

  "id" : "ConsumptionActive_ServicePoint",
  "name" : "ConsumptionActive",
  "srcType" : "ServicePoint",
  "tsDecl" : {
    "data": "consumptionReg",
    "treatment": "INTEGRAL",
    "start" : "consumptionDate",
    "end" : "consumptionDate + period(1, 'MONTH')",
    "filter": "(referenceDate!=null && endDate>=dateTime(referenceDate) && startDate<=dateTime(referenceDate))",
    "value": "totActive",
    "transform": "fillMissing(this,0)"
  },
  "variables"   :
  [
    {"name" : "referenceDate","dataType" : "string","description" : "datetime parameter"}
  ]
}

ConsumptionReactive (Simple):

{
  "id" : "ConsumptionReactive_ServicePoint",
  "name" : "ConsumptionReactive",
  "srcType" : "ServicePoint",
  "tsDecl" : {
    "data": "consumptionReg",
    "treatment": "INTEGRAL",
    "start" : "consumptionDate",
    "end" : "consumptionDate + period(1, 'MONTH')",
    "filter": "(referenceDate!=null && endDate>=dateTime(referenceDate) && startDate<=dateTime(referenceDate))",
    "value": "totReactive",
    "transform": "fillMissing(this,0)"
  },
  "variables"   :
  [
    {"name" : "referenceDate","dataType" : "string","description" : "datetime parameter"}
  ]
}

If the metrics have variables with name referenceDate then why is referenceDateActive & referenceDateReactive being passed in the bindings ?

Depending on the version of the platform you are using, the above feature should be supported. I believe the first version where this support was added was v7.8 (but I could be wrong)

Hi @rohit.sureka, thanks for your response. Using different binding variables referenceDateActive & referenceDateReactive is the workaround we have been forced into.

I added the code we would like to use below the page divider, where ConsumptionActive and ConsumptionReactive use the same referenceDate binding variable. Then we hit the error: “The variable name ‘referenceDate’ occurs multiple times in different compound metrics. This is currently not supported. You can temporarily change the variable name”

I can confirm this is not supported in v7.8 (7.8.10.233-1), but you think v7.9 incorporates this feature?

Yes this is expected to work in v7.9. Can you validate and if it doesn’t work can you raise a ticket?

@rohit.sureka sure thing, thank you!