The **calculate()** function is a user-defined script that enables custom calculations using [TBEL](${siteBaseUrl}/docs${docPlatformPrefix}/user-guide/tbel/) on telemetry and attribute data.
It receives arguments configured in the calculated field setup, along with an additional `ctx` object that stores `msgTs` and provides access to all arguments.
It receives arguments configured in the calculated field setup, along with an additional `ctx` object that stores `latestTs` and provides access to all arguments.
### Function Signature
@ -216,14 +216,14 @@ The return format depends on the output type configured in the calculated field
### Message timestamp
The `ctx` object also includes property `msgTs`, which represents the timestamp of the incoming telemetry message that triggered the calculated field execution in milliseconds.
The `ctx` object also includes property `latestTs`, which represents the latest timestamp of the arguments telemetry in milliseconds.
You can use `ctx.msgTs` to set the timestamp of the resulting output explicitly when returning a time series object.
You can use `ctx.latestTs` to set the timestamp of the resulting output explicitly when returning a time series object.
"delete-multiple-title":"Are you sure you want to delete { count, plural, =1 {1 calculated field} other {# calculated fields} }?",
"delete-multiple-text":"Be careful, after the confirmation all selected calculated fields will be removed and all related data will become unrecoverable.",
"test-with-this-message":"Test with this message",
"use-message-timestamp":"Use message timestamp",
"use-message-timestamp":"Use latest timestamp",
"hint":{
"arguments-simple-with-rolling":"Simple type calculated field should not contain keys with time series rolling type.",
"arguments-empty":"Arguments should not be empty.",
@ -1086,7 +1086,7 @@
"decimals-range":"Decimals by default should be a number between 0 and 15.",
"expression":"Default expression demonstrates how to transform a temperature from Fahrenheit to Celsius.",
"arguments-entity-not-found":"Argument target entity not found.",
"use-message-timestamp":"If enabled, the calculated value will be persisted using the timestamp of the telemetry that triggered the calculation, instead of the server time."
"use-message-timestamp":"If enabled, the calculated value will be persisted using the most recent timestamp from the arguments telemetry, instead of the server time."