Skip to main content

Hi, 

 

I am trying to set up a Custom Calculation to check if a variable is under many conditions, but I got stuck in a problem. The two limits (max and min) only get new data points in the data base when we change recipes. I tried to use .ffill() to fill the data base with the older values, but it did not work. I still get NaN results for the time I dont have values. 

 

 

Hi,

 

The .ffill() method only works if there are existing values in the interval you are fetching. The index_interval changes every time the script runs, since it defines the time window where new values should be calculated.

  • Backward indexing (when saving a new tag): the index_interval usually spans 30 days.

  • Forward indexing (when keeping a saved tag up to date): the index_interval is much shorter anywhere from a few minutes to a few hours.

If your limit tags (min and max) don’t have any data inside that index_interval, then .ffill() will return NaN, because there’s no previous value available in the requested range.

To solve this fetch a slightly larger time interval that extends before and after your calculation window. The size of this buffer should depend on how often your limit tags update.

  • Example: if your tags only update once a month, fetch at least one month of extra data in addition to the calculation interval.

Let me know if this solves your issue!

 

Kind regards

Frederik