{{getMsg('Help_YouAreHere')}}:
/
{{page.title}}
{{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}}
{{helpModel.downloadHelpPdfDataStatus}}
NthMostFrequent
Computes the nth most frequent element of a field or array. If multiple values with the same frequency occur, the smallest value is used as value with the greatest frequency.
It is possible to specify a condition which records to include.
Usage:
NthMostFrequent( n, fld ) NthMostFrequent( n, fld, condFld ) NthMostFrequent( n, fld, condFld, cond )
Parameters:
n | index of which largest element to take. |
---|---|
fld | The name of a field or array variable whose elements should be used to calculate the nth most frequent element. |
condFld | The name of the field that groups the elements of fld (if fld isn't an array). |
cond | A string declaring the type of grouping to be used on condFld. This only makes sense for groups based on Date, DateTime, Time, and Boolean fields. See Summary Field Conditions for a list of strings you can use here. |
Returns:
A number.
Examples:
// returns 7 because it is the most frequently occurring smallest value nthMostFrequent(1, [3,12,7,6,5,12,7])
// returns 12 because it is the most frequently occurring second smallest value nthMostFrequent(2, [3,12,7,6,5,12,7])
// returns the first most frequent value of the array nthMostFrequent(1, [2,5,3,2,9,2,4,3,2,5,7,8,5,1,2,6,4]) // returns 2
// returns the first most frequent value of the database field {Failures.Reason} nthMostFrequent(1, {Failures.Reason})
// returns the second most frequent Failures.Reason grouped by Vendor nthMostFrequent(2, {Failures.Reason}, {Vendors.Vendor})
// a formula that depends on the 10th most frequent value of Failures.Reason numberVar nth = nthMostFrequent(10, {Failures.Reason}); if {Failures.Reason} > nth then red else black
Notes:
-
If the values in fld should be grouped, a group based on condFld is needed. If the group does not exist in the report, you can add it using i-net Designer or using API method: Engine.addGroup.
-
If there are several values with the same frequency of occurrence, these group will be sorted in ascending order. So, the 3rd most frequent of [5,4,3,2,1] would be 3.