1 of 1 people found this helpful
Robert's example is a good approach, to give you some additional information:
To not overload the PI Data Archive or reach one of the max query parameters (ArcMaxCollect, MaxQueryExecution, etc) always limit the data volume you are querying.
A good practice (in the real world) is to not query raw data for more than a day at the time. Since this is a 0-1 value with likely not that many values you can likely without issues run it on a entire month (keep in mind how many values there is on the raw tag on many instances you can easily reach arcmaxcollect on just a week of data).
I had a draft that was a bit more advanced than Robert's example, Since I already drafted it I can publish it as well:
Month to date:
Year to date:
I've tried your method:
When I back fill, the Pump Active MtD calculation works fine, but the YtD and Grand Total calculations do not - I get 'Calc Failed'.
Any obvious reason why? Could it occur if I get bad values for the On/Off tag itself? If so, how can I get my calculation to filter these?
Thanks for your help,
Yes - if there is any bad data in one of your tags, it's possible you'll throw a "Calc Failed" error. There's a function you can use called BadVal() that can help. Here's a nice write-up on using this: KB00434 - How to filter out bad or undesired values from Performance Equations, Analyses, and AF Formulas
Here's a good example:
IF BadVal('tagname') THEN NoOutput() ELSE 'tagname' * 2
By leveraging an IF statement, you can basically return the function gracefully, rather than having it terminate due to an error.
In this use case, if BadVal('tagname') evaluates to TRUE (which it would, if 'tagname' had a system state, or something like that), the calculation will execute NoOutput(), which just means nothing happens. If BadVal() evaluated to false, then it would do it's normal calculation.