This article details the various functions and formulas you can use in your widgets.



When setting up an indicator in a widget, you can use different formulas and functions for your calculations.



1. Basic Operations :


You can perform additions, subtractions, multiplications, and divisions within widgets. You can reference site properties using the $ character and calculated indicators using the @ character. Multiple operations can be combined in the same formula, and the order of operations is respected.



2. Mathematical Functions Applied to Sensor Data :


  • MIN(@sensor): Returns the minimum value of the sensor over the period.
  • MAX(@sensor): Returns the maximum value of the sensor over the period.
  • COUNT(@sensor): Returns the number of values associated with the sensor over the period.

The COUNT function can also be used with a condition to count the number of values above, below, or equal to a fixed value. Use: COUNT(@sensor;<X) or COUNT(@sensor;>X). This also works with COUNT(SUM_SENSOR_LABELS();>X).



3. Grouping Sensor Data by Label :


You can call data from different sensors across single and multiple sites by using the associated label. Remember that a label can be added to a sensor via the asset file or the schematic. Only one label can be used per operation, and data aggregation is performed regardless of the sensor unit.

    • SUM_SENSOR_LABELS(label): Sums the values of all sensors (with the label) over the aggregation period.
    • MIN_SENSOR_LABELS(label): Provides the lowest aggregated value among all sensors (with the label)  over the given period.
    • MAX_SENSOR_LABELS(label): Provides the highest aggregated value among all sensors (with the label)  over the given period.
    • AVERAGE_SENSOR_LABELS(label): Provides the average of the aggregated values of all sensors (with the label)  over the given period.
    • COUNT_SENSOR_LABELS(label): Number of sensors with this label providing data over the period.


Example for three sensors with the same label:

    • Sensor 1: Daily interval (1 data point/day), aggregation = sum.
    • Sensor 2: Daily interval (1 data point/day), aggregation= average.
    • Sensor 3: Weekly interval (1 data point/week), aggregation = sum.

 

 

Sensor

Data Collected Week 1

Weekly Aggregation

Sensor 1 

7, 8, 7, 9, 7, 7, 5

50 (sum of all values)

Sensor 2 

6, 5, 8, 7, 7, 7, 9

7 (average of all values)

Sensor 3 

5

5 (sum of all values)

 

Data called via SENSOR_LABEL in a widget for "week 1":


Sum

Average

Min

Max

Count

Hourly aggregation 

X

X

X

X

X

Weekly aggregation 

(50 + 7 + 5)
62

(50 + 7 + 5)
/3
 20.7

5

50

3

 

 


4. Calling Sensor Data Based on Opening and Closing Hours:


The OPEN and CLOSE functions allow you to filter your results to keep only data associated with the site's opening (OPEN) or closing (CLOSE) hours. They only work when calling sensor data with an intra-daily time step through the formulas SENSOR BY LABEL.

    • OPEN(SUM_SENSOR_LABELS(label)): Sums the values of all labeled sensors during the site's opening hours only.
    • CLOSE(SUM_SENSOR_LABELS(label)): Sums the values of all labeled sensors during the site's closing hours only.
    • OPEN(MIN_SENSOR_LABELS(label)): Provides the lowest value among all sensors over the given period, keeping only values recorded during opening hours.
    • CLOSE(MIN_SENSOR_LABELS(label)): Provides the lowest value among all sensors over the given period, keeping only values recorded during closing hours.
    • OPEN(MAX_SENSOR_LABELS(label)): Provides the highest value among all sensors over the given period, keeping only values recorded during opening hours.
    • CLOSE(MAX_SENSOR_LABELS(label)): Provides the highest value among all sensors over the given period, keeping only values recorded during closing hours.
    • OPEN(AVERAGE_SENSOR_LABELS(label)): Provides the average value among all sensors over the given period during the site's opening hours only.
    • CLOSE(AVERAGE_SENSOR_LABELS(label)): Provides the average value among all sensors over the given period during the site's closing hours only.



5. Prorating Fixed Values Over a Given Period: "Number of..."


  • NB_SITE (data to compare; numeric condition): In multi-site settings, counts the number of sites meeting a numeric condition. The numeric condition can be =, >, >=, <, <= followed by the value you want to compare your data to.

Example: Count the number of sites with a usable area greater than or equal to 1000 m² using the formula NB_SITE($ Usable Area (-); >=1000)

  •  NB_HOUR, NB_DAY, NB_MONTH, NB_YEAR: These functions prorate fixed values according to the widget's periodicity. They are applied as a coefficient to your calculations.

Example: Determine a site's reference annual consumption as 30000MWh/year. Over a year, you can compare your actual consumption to your reference consumption. If you change the widget's periodicity to focus on a specific season, calculate the reference consumption for that period only to make a relevant comparison with the actual consumption. Apply a coefficient to your reference consumption so that it is calculated proportionally to the period via NB. Here, apply the NB_YEAR coefficient to multiply your reference consumption by the proportion of the year covered by the period.

  • NB_YEAR: Proportion of the year(s) covered by the widget's period. Example: If the widget period is one month, NB_YEAR = 1/12. If the widget period is one year, NB_YEAR = 1.
  • NB_MONTH: Proportion of months covered by the widget's period. Example: For a widget period of 2 years, NB_MONTH = 24. For a period of one day, NB_MONTH = 1/31, 1/30, or 1/28.
  • NB_DAY: Proportion of days covered by the widget's period. Example: For a widget period of one year, NB_DAY = 365. For a period of one month, NB_DAY = 30, 31, 28, etc.
  • NB_HOUR: Number of hours covered by the widget's period.


The formula is compatible with the OPEN & CLOSE functions (single site only)

  • NB_OPEN_HOUR: Number of hours the site was open during the widget period (returns results to the nearest quarter-hour).
  • NB_CLOSE_HOUR: Number of hours the site was closed during the widget period (returns results to the nearest quarter-hour).


  • AVERAGE_DAY(@indicator): Provides the daily average of a specific indicator.
  • AVERAGE_DAY(@indicator; day): Provides the daily average of a specific indicator on particular days only. Specify the days in English: AVERAGE_DAY(@indicator MONDAY).

Limit this calculation to a specific period: AVERAGE_DAY(@indicator; MONDAYFRIDAY; 01/01/2022; 31/03/2022).


  • NB_SITE (+ SBL; numeric condition): In multi-site settings, counts the number of sites with particular sensors meeting a numeric condition. Example: If the data labeled conso_enedis is measured in kWh, the formula NB_SITE(SUM_SENSOR_LABELS(conso_enedis); < 500) gives the number of sites where the energy consumed over the widget period is less than 500 kWh.