Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFSearch.GroupedSummaryAsync Method

  • Last UpdatedJan 12, 2026
  • 3 minute read
AFSearch.GroupedSummaryAsync Method
Generates summaries broken down by group for items matching the search criteria asynchronously.

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7

Syntax

public Task<AFGroupedResult<Object>> GroupedSummaryAsync(
	string groupedField,
	string summaryField,
	AFSummaryTypes summaryTypes,
	CancellationToken cancellationToken
)
Public Function GroupedSummaryAsync ( 
	groupedField As String,
	summaryField As String,
	summaryTypes As AFSummaryTypes,
	cancellationToken As CancellationToken
) As Task(Of AFGroupedResult(Of Object))

Dim instance As AFSearch
Dim groupedField As String
Dim summaryField As String
Dim summaryTypes As AFSummaryTypes
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of AFGroupedResult(Of Object))

returnValue = instance.GroupedSummaryAsync(groupedField, 
	summaryField, summaryTypes, cancellationToken)
public:
Task<AFGroupedResult<Object^>^>^ GroupedSummaryAsync(
	String^ groupedField, 
	String^ summaryField, 
	AFSummaryTypes summaryTypes, 
	CancellationToken cancellationToken
)
member GroupedSummaryAsync : 
        groupedField : string * 
        summaryField : string * 
        summaryTypes : AFSummaryTypes * 
        cancellationToken : CancellationToken -> Task<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.
cancellationToken
Type: System.ThreadingCancellationToken
A token to control cancellation of the aggregation request.

Return Value

Type: TaskAFGroupedResultObject
A result containing the requested summaries by group or an error if the summaries could not be performed.

Remarks

Note Notes to Callers
This call might use a background task to complete some of its work. See the Threading Overview for some matters to consider when execution transitions to another thread.

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 = await eventSearch.GroupedSummaryAsync("Element", "Duration", AFSummaryTypes.Average, CancellationToken.None);
    foreach (var group in groupedSummary.GroupedResults)
    {
        Console.WriteLine("Element: {0}, Average: {1}",
            group.Key, group.Value[AFSummaryTypes.Average]);
    }
}

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5, 2.9

See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in