
Re: Is there a PrevVal equivalent in the formula DR?
John Messinger May 17, 2017 11:29 PM (in response to arosenthal)2 of 2 people found this helpfulThe Formula DR is intended to be used for standard math functions, and has extremely limited support for PI specific functions (only badval and digstate). Archive functions such as PrevVal, PrevEvent etc aren't supported by this data reference. If the options you listed and have tried so far aren't giving you the intended results, I would consider moving the entire calculation to an Expression Analysis where the required archive functions are natively supported, and you can wrap the entire logic and functionality of your calculation in a single configuration location. Otherwise you may end up spending a lot of time trying to find a second rate workaround with the Formula DR.

Re: Is there a PrevVal equivalent in the formula DR?
arosenthal May 18, 2017 1:51 PM (in response to John Messinger)Thanks John, that's kind of what I figured about the Formula DR. I tried implementing my use case with Expression Analysis, but it seems to be more cumbersome than using the Formula DR to be honest. The problem I have with Expression Analysis is that for future data, the output is written only for a single time point. If I have multiple future time points I need to output, the analysis becomes very large and unmanageable. Using the Formula DR works better because it evaluates for every time point I request, so it "just works" with all client tools (as well as the PI Web API). Although I do agree with you that the Formula DR is limited in what calculations it can perform.
I did actually find a workaround though, albeit a clumsy one, for what I'm trying to accomplish. If I set up an AFTable that has a single field with a timestamp far in the future (say 12/31/9999 11:59:59 PM), then I can set up a Table Lookup DR on that table. The TLDR has to be configured to return a timeseries data, and will return the value of some other attribute (which can be a PI Point DR) when no matching row is found. This effectively makes an attribute whose value is the latest archived value of some tag no matter which time is requested.

Re: Is there a PrevVal equivalent in the formula DR?
John Messinger May 18, 2017 9:48 PM (in response to arosenthal)Yes, I agree that in this case for multiple time point outputs the Expression Analysis also has it's limitations. This is where Formula DR would have an advantage as you indicated. Glad you found a solution ("hacks" are often what we do, right?).
This is the interesting thing I've found with PI over the years  no matter what kind of use cases the developers anticipate for the software, seems we users can always find plenty of uses (edge cases perhaps) that either just never were identified, or were considered too far on the edge. Or, our business needs are just ever expanding requiring new ways to solve problems

Re: Is there a PrevVal equivalent in the formula DR?
tmcmanus May 23, 2017 3:02 PM (in response to arosenthal)Very interesting workaround Aaron. Does it accomplish what you were looking for?
As John says, we are always trying to continue developing features our users want and need, but our user base tends to come up with very creative uses for our system that we sometimes didn't realize was a need!
If you'd be willing to provide us insight and feedback into the usecase and goal you were working towards, it'd be a great addition to our Feedback Engine, where customers and employees can vote on topics, and our PMs review all of them. PI Server: Analytics & Calculations (70 ideas) – Customer Feedback for OSIsoft & the PI System

