{{getMsg('Help_YouAreHere')}}:
/
{{page.title}}
{{page.title}}
{{$root.getMsg("downLoadHelpAsPdf")}}
{{helpModel.downloadHelpPdfDataStatus}}
NthLargest
Computes the nth largest element of a field or array.
You can also give a condition which records to include.
Usage:
NthLargest( n, fld ) NthLargest( n, fld, condFld ) NthLargest( 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 largest 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 the n<sup>th</sup> largest element of the array\ nthlargest(4, [2,5,3,2,9,6,4,3,2,5,7,8,5,1,3,6,4]) //returns 6
//returns the n<sup>th</sup> largest element of the database field\ nthlargest(n, {Sales.Sales_Amount})
//returns the n<sup>th</sup> largest Sales_Amount grouped by Vendors\ nthlargest(n, {Sales.Sales_Amount, Vendors.Vendor})
//a formula that depends on the n<sup>th</sup> largest element of Sales_Amount\ numberVar nth = nthlargest(100, {Sales.Sales_Amount});\ if {Sales.Sales_Amount} > 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.