2 Replies Latest reply on Apr 9, 2018 5:49 PM by kduffy

    How to view PI Calculations in a Processbook



      is it possible to view all the PI Calculations in a ProcessBook? I have several ProcessBook with many PI Calculations, is there any possibility to view all the formulas in the PI Calculations at the same time? Because choosing every single PI Calculation one after another and viewing the formula is very time-consuming.

        • Re: How to view PI Calculations in a Processbook

          I recommend to use anlaysis to store the calculation results to PI Tag than using old technology such is Dataset.

          The latest technology is analysis with AF.  (I know Dataset does not require pi tags. But analysis also can be used without PI tags too) Maybe AF Formula also can be used for simple calculation. If you use AF, The calculation results can be used from PI ProcessBook. (Calculation itself is in AF, so it is easy to find and easy to manage than Dataset)


          PI Calculation (Dataset) can be achieved by client side and sometimes it causes performance issue/ difficult to find these syntaxes as you said.

          But if you need  to find these dataset, maybe VBA might help.

          The other way is PI ProcessBook support tool. But by default there are no function for searching PI Calculation by this tool.

          So you need to develop this feature.

          PI ProcessBook Support Tool Developers Guide


          I think it takes too much time for this task though.

          1 of 1 people found this helpful
            • Re: How to view PI Calculations in a Processbook

              I'd like to echo Kenji's comments; there are much better options in general than datasets within ProcessBook displays.


              With that being said, this could be a quick way to generate the list:

              1. add a microsoft list control (to hold the list of expressions) and a text box (or anything else to generate the trigger) with a good label (such as "populate list")


              2. Right click on the text box and select "Enable Scripting" so you can write a click event for it


              3. Add the following VBA code, or similar, by going to Tools > Macro > VB Editor

              Private Sub Text1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
              Dim dset As Dataset
              Dim calcset As PIExpressionDataset
              For Each dset In ThisDisplay.Datasets
                  If (dset.Type = 4) Then 'type 4 = ExpressionDataset
                      Set calcset = ThisDisplay.Datasets.GetDataset(dset.Name)
                      ThisDisplay.ListBox1.AddItem calcset.Name & ": " & calcset.Expression
                  End If
              Next dset
              End Sub


              This code loops through all the datasets in the display looking for type = 4, which is the ExpressionDataset. This gets rid of things like AF2, E_DS, MODULEDB, and any ODBC datasets you may have.

              Then it casts it as an expression dataset so it can access the expression property

              It then outputs the name of the dataset and its expression in the listbox so you can see them all at once.


              It should look something like this:



              I've attached the display I used to generate this so you can see it all put together.