AFSearch.FrequencyDistributionAsync Method
- Last UpdatedJan 12, 2026
- 3 minute read
- PI System
- AF SDK 3.2.0
- Developer
Generates a frequency distribution for the specified items asynchronously.
Namespace: OSIsoft.AF.Search
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.2.0.7
Syntax
public Task<AFGroupedResult<Object>> FrequencyDistributionAsync( string groupedField, CancellationToken cancellationToken )
Public Function FrequencyDistributionAsync ( groupedField As String, cancellationToken As CancellationToken ) As Task(Of AFGroupedResult(Of Object)) Dim instance As AFSearch Dim groupedField As String Dim cancellationToken As CancellationToken Dim returnValue As Task(Of AFGroupedResult(Of Object)) returnValue = instance.FrequencyDistributionAsync(groupedField, cancellationToken)
public: Task<AFGroupedResult<Object^>^>^ FrequencyDistributionAsync( String^ groupedField, CancellationToken cancellationToken )
member FrequencyDistributionAsync : groupedField : string * cancellationToken : CancellationToken -> Task<AFGroupedResult<Object>>
Parameters
- groupedField
- Type: SystemString
The field whose value should be grouped. - cancellationToken
- Type: System.ThreadingCancellationToken
A token to control cancellation of the aggregation request.
Return Value
Type: TaskAFGroupedResultObjectA result containing the requested frequency distribution or an error if the summaries could not be performed.
Remarks
| 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); // Generate a frequency distribution by primary element AFGroupedResult<object> frequencyDistribution = await eventSearch.FrequencyDistributionAsync("Element", CancellationToken.None); foreach (var group in frequencyDistribution.GroupedResults) { Console.WriteLine("Element: {0}, Count: {1}", group.Key, group.Value[AFSummaryTypes.Count]); } }