5 Replies Latest reply on Jun 20, 2016 6:47 PM by gachen

    Cummulative value calculation using PI Expression


      I am quite new to Processbook and PI in general. I am monitoring a tag over the course of the last 24 hours. I am wondering if I can create a dataset using PI Calc expressions which gives me the cumulative value of the tag at each point?


      A Very short Example:

      Time                                    Data           Cummulative Value (New dataset)

      01-03-16 17:00:01              0.002                     0

      01-03-16 17:00:02              0.010                     0.098

      01-03-16 17:00:04              0.013                     0.101

      01-03-16 17:00:05              0.002                     0.112

      01-03-16 17:00:06              0.001                     0.113

      01-03-16 17:00:10              0.040                     0.152


      Thanks in advance

        • Re: Cummulative value calculation using PI Expression

          I recommend using PI System Explorer for this. Create an analysis and the syntax goes like this.


          Prevval(temp,'*') + temp


          you would need to map it to another tag to store the data. Once the analysis is running you will just  display the tag on your processbook and dataset is not needed anymore. Also, I foresee that using dataset would not fit the job since you are looking at adding real time values at a certain interval.

            • Re: Cummulative value calculation using PI Expression

              Some great points here:


              1) Using an Analysis (which will store the calculations in an output tag) will let very easily trend the "Cumulative" tag alongside the original very easily

              2) Using an Analysis will allow you to control the output time stamps, and will make for a more seamless real-time usage


              We have plenty of great resources to help get you up to speed with AF Analytics if you're unfamiliar with these - here is one of our free online courses that can help you get started - Configuring Analytics with PI AF


              I'd also strongly recommend checking out our other free courses, such as the Visualization ones to see what might be helpful for you Learn PI 


              And lastly, we have a pretty stocked OSIsoftLearning - YouTube channel which can help to review when accomplishing specific tasks

              1 of 1 people found this helpful
            • Re: Cummulative value calculation using PI Expression

              Hi Glory,


              If you don't have Analysis. You can use a PI performance eq or dataset in processbook using the TagTot function:

              - Expression: Tagtot('yourPItag', '*-24h','*') *24 . This is a sliding Windows calculation (-24h until now). 24 is the conversion factor for yourpitag which have unit/hr as engineering unit, 1440 for unit/mn and 86400 for unit/s. Check out the PIperformanceEq document for this function.



              2 of 2 people found this helpful
              • Re: Cummulative value calculation using PI Expression

                Thanks for all your help! Problem solved.

                • Re: Cummulative value calculation using PI Expression

                  This is from another thread that I just responded to, but I thought it may be helpful here too:

                  I just want to add that in general, we discourage the use of PI Calculation Data Sets in PI ProcessBook, in favor of configuring an analogous AF Analysis, PE Equation or Totalizer point. There are several reasons for this:

                  • PI ProcessBook Calculation Data Sets need to be re-calculated with every refresh. If using one of the other options above, then the calculations are calculated once, and stored into a point. This should improve performance, especially for potentially expensive calculations. If you have many ProcessBook connections all running the same calculation, it can be a big hit on PI Data Archive's archive subsystem performance, because archive subsystem will need to calculate the result individually for each connection. However, storing the results in a point means archive subsystem only needs to retrieve already-calculated events.
                  • Storing the values in a point is much more scalable: the results can then be shared amongst different ProcessBook displays, as well as different clients, without needing each individual client to calculate the result independently.
                  • Storing the values in a point also give you the history of the calculations.