evalMetric: run-time bindings vs. static values

#1

It is possible to set a static value of a metric variable (see SimpleMetric and its field variables).
However, it seems that a static value takes precedence over dynamic bindings of the same variable, whereas I would expect the opposite, i.e., that the static value serve as the default value.
Is there a way to provide a default value of a metric variable, which can be overriden at run-time?

0 Likes

#2

You can always do something like that:

{
“id”: “MyParametricMetric_FinancialServicesAccountHolder”,
“name”: “MyParametricMetric”,
“srcType”: “FinancialServicesAccountHolder”,
“expression”: “exists(variable1) && exists(variable2) ? variable1 * 2 + variable2 : 2*2 + 1”,
“variables” : [{
“name” : “variable1”,
“dataType” : “double”
},{
“name” : “variable2”,
“dataType” : “double”
}]
}

c3Viz(FinancialServicesAccountHolder.evalMetricsWithMetadata({
expressions: [“MyParametricMetric”],
ids: [“test_FSAH_1”],
start: “2018-01-01”,
end: “2018-01-08”,
interval: “DAY”, bindings: [{“variable1”: 3, “variable2”: 4}]
}, [m]))

returns 10

c3Viz(FinancialServicesAccountHolder.evalMetricsWithMetadata({
expressions: [“MyParametricMetric”],
ids: [“test_FSAH_1”],
start: “2018-01-01”,
end: “2018-01-08”,
interval: “DAY”
}, [m]))

returns 5

1 Like

#3

Thanks. The expression needs to grow… And by the same logic, static value field is not needed at all, that’s also a bit the opposite of what’s needed.

0 Likes