M_data set to string instead of actual metric result


I’ve a metric with binding that’s been evaluated like the following

function resultKey(expression, bindings) {
  return bindings['r'] + '_' + bindings['mt'];
var res = Facility.evalMetrics({
   ids: ['0001'],
   expressions: ['SmartMeterMeasurementSumOverObjsSumOverTime'],
   start: DateTime.nowWithoutZone().toDateMidnight().plusDays(-1),
   end: DateTime.nowWithoutZone().toDateMidnight().plusDays(1),
resultKey: Lambda.fromJavaScript(resultKey),
   interval: 'DAY',
   include: 'bindings',
   bindings: [{r: 'Electricity', mt: 'consumption'}, {r: 'naturalgas', mt: 'consumption'}, {r: 'h_water', mt: 'consumption'}, {r: 'Cooling_Water', mt: 'consumption'}, {r: 'steam', mt: 'consumption'}]

The problem is in the returning results, fields m_data is set to an array of strings consumption, here is a screenshot:

When removing the lambda definition field resultKey from the EvalMetricsSpec, I get the expected results however I can no longer match my binding values to timeseries results as depicted:

Any clues how I can use resultKey to generate the key for the metric expression results and get the m_missing and m_data been properly defined?


Apparently I have to use the parameter expression that was passed to the lambda function resultKey otherwise the system.

Updating the resultKey to the following fixes the problem:

function resultKey(expression, bindings) {
  return expression + '_' + bindings['r'] + '_' + bindings['mt'];