3 Replies Latest reply on Aug 19, 2010 11:29 PM by Bryan Owen

    Displaying 5 lowest tag values (ProcessBook)

      Hello all,

      What i am essentially trying to do is create a table, in ProcessBook, that displays the five lowest values from a tag over the past 7 days. A task that sounds simple enough, but it is giving me quite a bit of grief. These values can update every minute, are numeric, and are all from the same tag.

        Any ideas on how I go about this would be greatly appreciated.




        • Re: Displaying 5 lowest tag values (ProcessBook)

          I suggest a 3 step aproach :


          - install PI OLEDB (not PI OLEDB Enterprise)


          - open the example in \PIPC\OLEDB\Samples\ADO\ADO Intro\PI-ProcessBook


          - try the following query:

          SELECT TOP 5 tag, time, value, status FROM piarchive..picomp2
          WHERE tag = 'sinusoid' AND time > '*-7d' ORDER BY value ASC

          The query will return the TOP 5 values from the archive, and the order will be ASCending by value.


          The query is executed via VBA, so you will have to open the VBA editor and locate the adoRs.Open line.


          Hope this helps

            • Re: Displaying 5 lowest tag values (ProcessBook)

              If you didn't want to go the OLEDB route, you could use PISDK in the VBA of your display and output your results to a table (FlexGrid?) on the display.  The PISDK to FlexGrid route could be as simple as retrieving the recorded values from a PIPoint over a 7 day period and extract the 5 lowest tag values.


              It is a shame that when you use the recordset property of a PIValues collection that you cannot sort on the "Value" field.

            • Re: Displaying 5 lowest tag values (ProcessBook)
              Bryan Owen

              Just curious...are there concerns about the 5 lowest values coming from distinct sags in the waveform?  This too can be kind of tricky.  It seems you might want to augment the approach with some server side processing (ACE / PE / SQC / TOTALIZER).