The values of any plant accessible by the connected user, who can use signal values, metadata and fixed values, and also other special values described below, can be used in the KPI formula.
@tagName
Refers to the tag value of a plant.
In the case of live calculation, each change in @tagName generates a KPI datapoint.
In the case of periodic calculation, the KPI datapoint is always only one for each period, regardless of the number of changes that the @tagName has had.
@metadataName
Refers to the metadata value of a plant.
NOTE: in the case of live KPIs, any change in the metadata DOES NOT trigger the calculation of the KPI, which is triggered only by the change in a variable linked to a tag.
The value of the metadata, being a free text, must necessarily follow these rules in order to be interpreted correctly:
- It must contain only the number, without units of measurement or anything else.
- Must not contain thousands separators.
- The possible decimal separator can be either a comma or a period. Both symbols are considered decimal separators.
@@TS_UTC(@tagName)
@@TS_local(@tagName)
They represent the timestamp relating to the tag datapoint, in UTC and in the plant’s timezone, respectively.
In the case of periodic calculation, they are the last timestamp available within the calculation time window.
Example with a plant with a timezone in Italian time:
– 2022-12-31 09:05:00 Italian time: temperature 20.1°
@@TS_UTC value is ‘2022-12-31 08:05:00’
@@TS_local value is ‘2022-12-31 09:05:00’
@@THIS
Indicates the previous value of the KPI, before the current calculation.
Example:
I created a new KPI, at 8:59 am on December 31, 2022, with the formula:
@partialCounter + ISNULL(@@THIS, 0);
– 2022-12-31 09:00:00: @partialcounter = 100 → KPI = 100.
– 2022-12-31 09:05:00: @partialcounter = 80 → KPI = 180
At the time of the 9:05 calculation, @@THIS is 100, and therefore the 9:05 KPI is equal to 80 + 100 = 180.
@@TS_UTC(@@THIS)
@@TS_local(@@THIS)
They represent the timestamp relating to the current calculation of the KPI, in UTC and in the plant’s timezone, respectively.
ATTENTION: for periodic KPIs they are influenced by the @@TIMESTAMP_POSITION directive.
Example with a plant with a timezone in Italian time:
The KPI formula is:
@@CALCULATE_EVERY = 1 HOUR;
IIF(DATEPART(HOUR, @@TS_local(@@THIS)) < 12, @tOut, @tIn);
The meaning is: if the time is between 00:00 and 11:59 I take the external temperature @tOut, otherwise I take the internal temperature @tIn.
– 2022-12-31 11:00:00 Italian: tOut = 10.1, tIn = 19.8 → KPI = 10.1
– 2022-12-31 12:00:00 Italian: tOut = 10.3, tIn = 20.1 → KPI = 20.1
@@PreviousTS_UTC(@@THIS)
@@PreviousTS_local(@@THIS)
They represent the timestamp relating to the previous calculation of the KPI, in UTC and in the plant’s timezone, respectively.
ATTENTION: for periodic KPIs they are influenced by the @@TIMESTAMP_POSITION directive.
Example with a plant with a timezone in Italian time:
The KPI formula is:
DATEDIFF(SECOND, @@PreviousTS_local(@@THIS), @@TS_local(@@THIS)) * ((@@PreviousValue(@flowLitriMinuto) + @flowLitriMinuto) / 2) / 60;
The meaning is: I want to calculate how many liters have passed through the channel, starting from the flow rate, which is expressed in liters per minute. To make a more precise calculation, I still calculate the difference in seconds (DATEDIFF always gives an integer result, not a fractional one), and then divide by 60. As a flow rate value, I don’t take the current value, but I do an average between the current value and the previous value.
– 2022-12-31 09:00:00 Italian: flow rate l/min: 10
– 2022-12-31 09:05:00 Italian: flow rate l/min: 18
The individual components for the 9:05 calculation are:
– @@PreviousTS_local(@@THIS) = 2022-12-31 09:00:00
– @@TS_local(@@THIS) = 2022-12-31 09:05:00
– @@PreviousValue(@flowLitriMinuto) = 10
– @flowLitriMinuto = 18
And so the result is:
300 * ((10 + 18) / 2) / 60 = 70 litres
Was this helpful?
0 / 0