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

AF SDK Reference

AFSearch.FrequencyDistribution Method

  • Last UpdatedNov 18, 2025
  • 3 minute read
AFSearch.FrequencyDistribution Method
Generates a frequency distribution for the specified items.

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

Syntax

public AFGroupedResult<Object> FrequencyDistribution(
	string groupedField
)
Public Function FrequencyDistribution ( 
	groupedField As String
) As AFGroupedResult(Of Object)

Dim instance As AFSearch
Dim groupedField As String
Dim returnValue As AFGroupedResult(Of Object)

returnValue = instance.FrequencyDistribution(groupedField)
public:
AFGroupedResult<Object^>^ FrequencyDistribution(
	String^ groupedField
)
member FrequencyDistribution : 
        groupedField : string -> AFGroupedResult<Object> 

Parameters

groupedField
Type: SystemString
The field whose value should be grouped.

Return Value

Type: AFGroupedResultObject
A result containing the requested frequency distribution 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);
    // Generate a frequency distribution by primary element
    AFGroupedResult<object> frequencyDistribution = eventSearch.FrequencyDistribution("Element");
    foreach (var group in frequencyDistribution.GroupedResults)
    {
        Console.WriteLine("Element: {0}, Count: {1}",
            group.Key, group.Value[AFSummaryTypes.Count]);
    }
}
' 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)


    ' Generate a frequency distribution by primary element
    Dim frequencyDistribution As AFGroupedResult(Of Object) = eventSearch.FrequencyDistribution("Element")
    For Each group As KeyValuePair(Of Object, IReadOnlyDictionary(Of AFSummaryTypes, AFValue)) In frequencyDistribution.GroupedResults
        Console.WriteLine("Element: {0}, Count: {1}", group.Key, group.Value(AFSummaryTypes.Count))
    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.

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