AFSearch.GroupedSummary Method
- Last UpdatedNov 18, 2025
- 3 minute read
- PI System
- AF SDK 2024 R2
- Developer
Generates summaries broken down by group for items matching the search criteria.
Namespace: OSIsoft.AF.Search
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public AFGroupedResult<Object> GroupedSummary( string groupedField, string summaryField, AFSummaryTypes summaryTypes )
Public Function GroupedSummary ( groupedField As String, summaryField As String, summaryTypes As AFSummaryTypes ) As AFGroupedResult(Of Object) Dim instance As AFSearch Dim groupedField As String Dim summaryField As String Dim summaryTypes As AFSummaryTypes Dim returnValue As AFGroupedResult(Of Object) returnValue = instance.GroupedSummary(groupedField, summaryField, summaryTypes)
public: AFGroupedResult<Object^>^ GroupedSummary( String^ groupedField, String^ summaryField, AFSummaryTypes summaryTypes )
member GroupedSummary : groupedField : string * summaryField : string * summaryTypes : AFSummaryTypes -> AFGroupedResult<Object>
Parameters
- groupedField
- Type: SystemString
The field whose value should be grouped. - summaryField
- Type: SystemString
The field that should be summarized for each group. - summaryTypes
- Type: OSIsoft.AF.DataAFSummaryTypes
The types of summaries to perform for each group.
Return Value
Type: AFGroupedResultObjectA result containing the requested summaries by group or an error if the summaries could not be performed.
Examples
// Get the Database PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; if (myPISystem == null) throw new InvalidOperationException("Default PISystem was not found."); AFDatabase myDB = myPISystem.Databases[dbName]; if (myDB == null) throw new InvalidOperationException("Database was not found."); // Create a search to find all the event frames created from the 'Event' // template in the last year. using (AFEventFrameSearch eventSearch = new AFEventFrameSearch(myDB, "EventFrameSearch", @"Template:'Event' Start:>'t-1y'")) { eventSearch.CacheTimeout = TimeSpan.FromMinutes(10); // Get the average duration grouped by primary element AFGroupedResult<object> groupedSummary = eventSearch.GroupedSummary("Element", "Duration", AFSummaryTypes.Average); foreach (var group in groupedSummary.GroupedResults) { Console.WriteLine("Element: {0}, Average: {1}", group.Key, group.Value[AFSummaryTypes.Average]); } }
' Get the Database Dim myPISystems As New PISystems() Dim myPISystem As PISystem = myPISystems.DefaultPISystem If myPISystem Is Nothing Then Throw New InvalidOperationException("Default PISystem was not found.") End If Dim myDB As AFDatabase = myPISystem.Databases(dbName) If myDB Is Nothing Then Throw New InvalidOperationException("Database was not found.") End If ' Create a search to find all the event frames created from the 'Event' ' template in the last year. Using eventSearch As New AFEventFrameSearch(myDB, "EventFrameSearch", "Template:'Event' Start:>'t-1y'") eventSearch.CacheTimeout = TimeSpan.FromMinutes(10) ' Get the average duration grouped by primary element Dim groupedSummary As AFGroupedResult(Of Object) = eventSearch.GroupedSummary("Element", "Duration", AFSummaryTypes.Average) For Each group As KeyValuePair(Of Object, IReadOnlyDictionary(Of AFSummaryTypes, AFValue)) In groupedSummary.GroupedResults Console.WriteLine("Element: {0}, Average: {1}", group.Key, group.Value(AFSummaryTypes.Average)) Next End Using
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.