Calculated Metrics Revisited
In an earlier article we introduced calculated metrics, a powerful feature that allows real-time calculations on other metrics. Calculations typically involve manipulating numbers. However, sometimes it can be useful to have textual input to your calculation or even to output a value of type text. Calculated metrics have been upgraded to support just that!
Properties and other metrics can be used as arguments of a calculated metric. They serve as inputs and are available as variables in the calculation. Those arguments can be of type number, location or (new!) text.
Let’s say, for example, that you have a sensor for measuring soil moisture. Perhaps the sensor behaves differently based on the type of soil and you want to compensate for that. If the soil type is available as a textual property, you can use its value to correct the measured moisture in a calculated metric:
In addition to accepting textual arguments, calculated metrics can now also output text values. We can use this, for example, to convert a cryptic status code into a readable text. When creating a calculated metric, you can choose its type: Number or Text. If you choose Text, you need to output a text at the end of the script:
To help ensure error-free scripts, the system checks for discrepancies and notifies you of any issues. For example, when you compare a number to a text, or you output a number while the calculated metric is of type Text. In all these cases, a helpful message will appear:
Auto-completion in the calculated metrics editor is now more intelligent. After typing the name of a property or metric, the suggested field names are now limited based on the type of the property or metric. So, “number” and “date” are suggested for a number metric, but “longitude” is not:
Note that the numeric value of a number metric or property is now being referred to as
.number instead of
.value. The latter is still supported but deprecated. The textual value of a text metric or property can be accessed through
We added visual feedback to the metrics overview so you can quickly identify calculated metrics that are incorrect. There are two ways in which a calculation can be invalid:
- The calculation script has errors. Details of those errors can be found in the calculation editor.
- The calculated metric has no metric arguments. Without a metric argument, there is nothing that will trigger the calculation.
Ready to try it out?
To sum up, text support improves the expressiveness of calculated metrics, enabling you to manipulate your data in new ways. We hope you like the new features, and we’re certain you’ll find ways to use them that we haven’t even imagined!
If you’re interested in using Blockbax but haven’t started yet, send us a message and we’ll reach out to explore potential opportunities.
The Blockbax Team