Skip to main content

Formula

The Formula feature enables users to modify the visualization of data in specific widgets. Located inside the configuration tab of most widgets, a Formula can be applied to all fields of a stored register, including variable, value, unit, group, location, and metadata.

How it works

The system receives input data from a variable in your Device, applies a formula to generate a temporary output value, and displays that output in the widget. This output is only for visualization and is not saved as a variable in device data storage.

Example flow:

Example formula (text):

$value$ * 2 + 5

Formula configuration in widgets

The Formula configuration is available inside most widget configuration panels. It produces a temporary, visual-only value and does not alter the stored device data.

Formula

Typical elements in the Formula panel include:

Example formula (temperature conversion):

($VALUES$ - 273.15) * 9/5 + 32

Notes

Source options

When configuring a formula you can choose between two source types:

Operators

The following operators are available in Formula expressions:

OperatorNameExample+, -add, subtract$value$ + 1000/, *divide, multiply$value$ / 2.14tounit conversion$value$ inch to cm? :conditional expression$value$==1 ? $VALUE$ ON : OFF>>, <<arithmetic shifts$VALUE$ >> 1sqrt, sin, logmath operationssqrt ($value$)

More operators can be found on Math.js.

Date & Time Operations

The Date() function formats date and time values dynamically.

Syntax

Date(source, format_string)

Special variables are replaced at runtime based on the current TagoRUN user’s settings.

Formula ExampleDescriptionExample OutputDate($METADATA.shipped_at$, "$DATE_FORMAT$ $TIME_FORMAT$")Formats a metadata date using user preferences07/23/2024 14:30Date($VALUE$, "$DATE_FORMAT$ HH:mm:ss")Custom time with user date format23/07/2024 18:45:10Date($VALUE$, "YYYY-MM-DDTHH:mm:ss[Z]")ISO 8601 format for timestamps2024-07-23T18:45:10ZDate($TIME$, "HH:mm")Time only, 24‑hour format14:30

Formula application examples

To visualize a temperature in Fahrenheit when the device stores Celsius:

$VALUE$ celsius to fahrenheit

or

($VALUE$ × 9/5) + 32

More options are available in the dropdown list of the Formula field.

Units for output variables

After converting a value, you can set the unit that appears next to it. Use the Unit Origin field to define where the displayed unit comes from. Learn more about Display Units.

Minimum and Maximum limits

The formula does not adjust the widget’s data range. The Min and Max values are still controlled by the settings in the Data Range tab.

Dynamic Formulas

Dynamic Formulas allow formulas to adapt based on user preferences or browser settings. To use them:

  1. Create a new visualization preference in TagoRUN via Custom Settings.
  2. In the widget’s configuration, enable Dynamic Formula and select:

Dynamic Formulas are especially useful for letting users choose units (Celsius, Fahrenheit, Kelvin) or other display options that automatically adjust across dashboards.