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