Click or drag to resize
OSIsoft, LLC

AFSearchGroupedSummary Method

Generates summaries broken down by group for items matching the search criteria.

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version:
public AFGroupedResult<Object> GroupedSummary(
	string groupedField,
	string summaryField,
	AFSummaryTypes summaryTypes


Type: SystemString
The field whose value should be grouped.
Type: SystemString
The field that should be summarized for each group.
Type: OSIsoft.AF.DataAFSummaryTypes
The types of summaries to perform for each group.

Return Value

Type: AFGroupedResultObject
A result containing the requested summaries by group or an error if the summaries could not be performed.
// 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]);
Version Information


Supported in: 2.10.5, 2.10, 2.9.5, 2.9
See Also
Enabling Operational Intelligence