MarkLogic 12 EA 1 Product Documentation
math.percentRank

math.percentRank(
   arg as (String | Number | Boolean | null | Array | Object)[],
   value as xs.anyAtomicType,
   [options as String[]]
) as Number?

Summary

Returns the rank of a value in a data set as a percentage of the data set. If the given value is not equal to any item in the sequence, the function returns the empty sequence. See math:rank.

Parameters
arg The sequence of values.
value The value to be "ranked".
options Options. The default is ().

Options include:

"ascending"(default)
Rank the value as if the sequence was sorted in ascending order.
"descending"
Rank the value as if the sequence was sorted in descending order.
"collation=URI"
Applies only when $arg is of the xs:string type. If no specified, the default collation is used.
"coordinate-system=name"
Applies only when $arg is of the cts:point type. If no specified, the default coordinate system is used.

Example

  math.percentRank([1, 7, 5, 5, 10, 9],9)

  => 0.833333333333333
Powered by MarkLogic Server | Terms of Use | Privacy Policy