2 Replies Latest reply on Feb 8, 2018 8:43 PM by TuiBray

    Processbook Nested If Time Calculation

    TuiBray

      Hi.  Just wondering is it possible in ProcessBook to do a calculation of the percentage of time that a PI tag is below a specified value whenever another tag is above zero for the year to date?

       

      ie calculate the time for the year to date that (TagVal('TagA') >0 and TagVal('TagB') < X

       

      And if this is possible, is it possible to do a cumulative Year to Date line of the % on a plot?

       

      Thanks

        • Re: Processbook Nested If Time Calculation
          mtippett

          Hi Tui,

           

          I think you are talking about doing this in Processbook datasets, is that correct?  Assuming you are, here is a sample dataset configuration for the tag 'sinusoid'

           

          100 * (TimeLT('sinusoid','1-Jan','*',50) - TimeLE('sinusoid','1-Jan','*',0)) / ( DaySec('*') + (Yearday('*')-1)*86400 )

           

          To break this down, a bit:

          TimeLT('sinusoid','1-Jan','*',50) - returns the number of seconds that the tag sinusoid is less than 50 over the time period 1-Jan of current year to execution time

          TimeLE('sinusoid','1-Jan','*',0) - returns the number of seconds that the tag sinusoid is less than or equal to 0 over the time period 1-Jan of current year to execution time

          DaySec('*') - returns the number of elapsed seconds in the current day

          Yearday('*') - returns the number of the current day, i.e. 1 for 1-Jan, 32 for 1-Feb etc.

           

          The numerator of the equation above finds the number of seconds sinusoid was less than 50 and greater than 0 (multiplied by 100 get get a percentage), and the denominator finds the number of elapsed seconds the current year.  The result is below, as expected the percentage varies a a lot initially and settles out at just below 50%.

           

           

          Note that this method doesn't take daylight savings into account, so there will be some errors in the calculation, though it might need someone smarter than me to work that issues out.

          1 of 1 people found this helpful