2 Replies Latest reply on Mar 10, 2018 12:48 AM by gachen

    Find the last Value and Time, where value for a tag greater then zero

    jainc_paresh

      Hello Team,

       

      Greetings for the day!

       

      For a given tag using PI PE or PI Analysis I need to find out the last value and time where value greater than zero. (FindGE dont will not work as I wont know the time, so cant give a time range)

      In current snap shot I need Value 242.8222 and Event time as 2/12/2018 2:52:10 AM

       

       

      Thanks in advance.

        • Re: Find the last Value and Time, where value for a tag greater then zero
          Rhys Kirk

          FindEQ and NextEvent will work, you can reverse the dates so that it works backwards in time. You can use an early time for the end, e.g. 1 year, to walk backwards until you find the first occurrence.

           

          Time (of last 0) = FindEq('Tag1','*','*-365d', 0)

          Time (after last 0) = NextEvent('Tag1',FindGT('Tag1','*','*-365d', 0))

          Value (after last 0) = NextVal('Tag1',FindGT('Tag1','*','*-365d', 0))

           

          Edit: Okay, read your question properly and altered my post.

          • Re: Find the last Value and Time, where value for a tag greater then zero
            gachen

            Just keep in mind that doing it via the 'find' functions like FindEq, FindGT, FindLT can be very expensive, particularly for longer time ranges and PI points with higher density data. If this is something you want to roll-out to many different attributes/points and keep as a reference, you may want to consider setting up naturally-scheduled analyses with the logic to check and store the appropriate events/times as the events come in. This way you have the value stored for reference, rather than needing to compute it each time with FindEq/FindGT/FindLT.