7 Replies Latest reply on Mar 30, 2016 8:37 PM by rochoas

    Obtain averages of active trends ProcessBook ..

    rochoas

      Hi all :

      Please , I need your help

      I need to get average , maximum and minimum of each data ( 3 tags ) found in the trend in ProcessBook . ...

      Regards.

        • Re: Obtain averages of active trends ProcessBook ..
          Asle Frantzen

          Hello. This is fairly simple - while in Run mode open the Details pane (View->Details), and select Statistics in the top right dropdown menu. Then click your trend to select it, and use the dropdown menu for data item (top left in the Details pane) to select the individual PI Points to get statistics on.

           

          This will follow the timerange of the trend.

          2 of 2 people found this helpful
            • Re:  Obtain averages of active trends ProcessBook ..
              rochoas

              It´s correct, but I need that the average is displayed in the screen automatic automatically and I can modify the size of the trend and recalculated again the aerage.

               

              Regards,

                • Re:  Obtain averages of active trends ProcessBook ..
                  Asle Frantzen

                  Then it's not so straight forward.

                   

                  For data coming from AF: You'd have to configure an AF attribute as a PI Point data ref. (in AF) and set the advanced settings for that. Min/Max/Avg and then set timerange as the next setting. When you use this AF attribute in ProcessBook the time range of your display would be sent to AF, and then the correct data would be returned. The time range of the display is determined by the time range of the first trend object being placed onto the display.

                   

                  For data coming from the PI Server / PI Data Archive as a tag: I haven't done this myself but it'd require some VBA scripting skills, where you create a PI Calc dataset and update the time ranges through the code.

                    • Re:  Obtain averages of active trends ProcessBook ..
                      rochoas

                      I took an example having the ProcessBook and change it , but I get a different result to that shown in Show Details and Annotations.

                       

                      It´s this.

                       

                      Private Sub Average()

                          Dim i As Long

                          Dim Value As Variant, ValTime As Variant, ValStatus As Variant

                          Dim MinVal As Single, MaxVal As Single, Avg As Single, Count As Single

                            

                          Dim GoodVals As Boolean

                          'only one trend on display: Trend

                         Trend.CurrentTrace = 1

                          GoodVals = False

                          Count = Trend.TraceValuesCount

                          For i = 1 To Trend.TraceValuesCount

                              Value = Trend.GetTraceValue(i, ValTime, ValStatus)

                              If (ValStatus = 0) Then

                                  If (GoodVals) Then

                                      If (Value < MinVal) Then MinVal = Value

                                      If (Value > MaxVal) Then MaxVal = Value

                                      Avg = (Avg + Value) / Count

                                      txtCount = Count

                                      Else

                                      MinVal = Value

                                      MaxVal = Value

                                      GoodVals = True

                                  End If

                              End If

                          Next i

                          If (GoodVals) Then

                              txtMax.Text = MaxVal

                              txtMin.Text = MinVal

                              txtAvg.Text = Avg

                              txtCount = Count

                          Else

                              txtMax.Text = "No Good Values"

                              txtMin.Text = "No Good Values"

                              txtAvg.Text = "No Good Values"

                          End If

                          txtRecalcTime.Text = Now()

                          ThisDisplay.Modified = False

                      End Sub