I am currently working with VBA in PI Processbook and got stuck on a problem. I have a sheet with a large number of PI tags, each having a button of their own. When that button is clicked, that tag is plotted as a trace on a trend. In addition to this, it also updates a pre-defined calculated dataset (please correct my terminology if I am wrong) based on some other tags in relation with this one. This dataset is also on the trend.
I would now like to perform calculations on this dataset. Particularly, I would like to calculate the Min, Max, St.Dev, and Mean of this dataset. However, the catch is, I would like to calculate these statistics for only the time range of the trend. This time range is dynamic and can be set by the user.
How do I go about doing this? So far, the code I have is as follows:
Private Sub recalculate() Dim ptPoint As PISDK.PIPoint Dim ds As Datasets Dim calc As PIExpressionDataset Set ptPoint = PISDK.Servers("ServerNameHere").PIPoints("PreTagHere" & Text1.Contents) Set ds = ThisDisplay.Datasets Set calc = ds.GetDataset("Spec_Calc") With calc .Expression = "'PreTagHere" & Text1.Contents & "Suffix1' - 'PreTagHere" & Text1.Contents & "Suffix2'" .Interval = "1m" .ColumnName = "Value" .RefreshInterval = 60 .Description = "Calculated Factor" .Stepped = False End With Call ds.SetDataset(calc) averagetag.Contents = ptPoint.Data.Summary(TextBox1.Text, TextBox2.Text, astAverage, cbTimeWeighted) End Sub
As you can see in the above code, I was successfully able to calculate the average of the data in the trend easily, because it was a PI tag. However, I'm not sure how to do the same with a DataSet (in this case, "calc").
Thanks for your help