How to calculate using AF expressions the total time within a time range where the value is between a value range? Running analyses at each new value to do a comparison is not an option as the values update very frequently.
You can use a combination of the TimeGE (Time greater than or equal to) and TIMELE (Time less than or equal to) functions and setup an analysis to calculate when the value of an attribute was in a specific time range. More information can be found here:
1. TIMEGE -
https://livelibrary.osisoft.com/LiveLibrary/content/en/server-v13/GUID-C0DEC147-DA5C-4A42-B17C-D91FBE9E95272. TIMELE - https://livelibrary.osisoft.com/LiveLibrary/content/en/server-v13/GUID-AAC8E4ED-1356-4273-8EEE-38BFAE03C301
We have almost this exact example in our public class when we have students practice expression syntax (link to class workbook below if interested). Basically you use two similar TimeXX functions and take the difference to get the total time in the value range. The only kind of tricky thing is deciding how you want to handle the boundary values; do you want to include or exclude times when the tag is exactly equal to a boundary value?
For example, if you want to exclude times when the value is equal to either boundary, you could use the following for a time range of yesterday and boundary values of 10 and 90:TimeLT('Attribute','y','t', 90) - TimeLE('Attribute','y','t',10)Use other functions if you want to handle boundary conditions differently.Please let us know what you think or if you have any further questions.AF Class workbook: https://osicdn.blob.core.windows.net/learningcontent/pdfs/Building%20PI%20System%20Assets%20v2018%20SP2.pdf
Retrieving data ...