Ubidots Community

Synthetic variable function

Hello friends, I have been searching but I have not been able to find, I need some synetica variable function that allows me to count the number of times a value is exceeded in a certain time range, thank you very much friends!

Hello @PabloKnales,

There are 2 options to get your expected result. I list them below:

  1. Synthetic variables: you’ll need to create 2 variables, one to track when the value is exceeded and the second to simply count those how many times the value is exceeded. Here are both expressions:
    A) where(var > X, 1) this will inject a 1 every time the value of var is greater than X. For the sake of this example, let’s call this synthetic variable “limit-tracker”.
    B) count(limit-tracker, "1D") this will count the 1’s in limit-tracker per day. You can find other ranges different from day in the below article
  1. Synthetic variable and widget’s aggregation method combo: you’ll need to create the synthetic variable A) described in option 1. Then use the widgets’ aggregation methods capability to count the 1’s from that synthetic variable. You should set the widget aggregation method to “Count” and its Span to whatever the time range you need.