#
Ranking and clustering functions

These functions can only be used in chart expressions.Use the drop-down on each function to see a brief description and the syntax of each function. Click the function name in the syntax description for further details.

## Ranking functions in charts

Rank() evaluates the rows of the chart in the expression, and for each row, displays the relative position of the value of the dimension evaluated in the expression. When evaluating the expression, the function compares the result with the result of the other rows containing the current column segment and returns the ranking of the current row within the segment.

**rank**([TOTAL [<fld {, fld}>]] expr[, mode[, fmt]])

HRank() evaluates the expression, and compares the result with the result of the other columns containing the current row segment of a pivot table. The function then returns the ranking of the current column within the segment.

**HRank**([TOTAL] expr[, mode[, fmt]])

## Clustering functions in charts

KMeans2D() evaluates the rows of the chart by applying k-means clustering, and for each chart row displays the cluster id of the cluster this data point has been assigned to. The columns that are used by the clustering algorithm are determined by the parameters coordinate_1, and coordinate_2, respectively. These are both aggregations. The number of clusters that are created is determined by the num_clusters parameter. Data can be optionally normalized by the norm parameter.

**KMeans2D**(num_clusters, coordinate_1, coordinate_2 [, norm])

KMeansND() evaluates the rows of the chart by applying k-means clustering, and for each chart row displays the cluster id of the cluster this data point has been assigned to. The columns that are used by the clustering algorithm are determined by the parameters coordinate_1, and coordinate_2, etc., up to n columns. These are all aggregations. The number of clusters that are created is determined by the num_clusters parameter.

**KMeansND**(num_clusters, num_iter, coordinate_1, coordinate_2 [,coordinate_3 [, ...]])

KMeansCentroid2D() evaluates the rows of the chart by applying k-means clustering, and for each chart row displays the desired coordinate of the cluster this data point has been assigned to. The columns that are used by the clustering algorithm are determined by the parameters coordinate_1, and coordinate_2, respectively. These are both aggregations. The number of clusters that are created is determined by the num_clusters parameter. Data can be optionally normalized by the norm parameter.

**KMeansCentroid2D**(num_clusters, coordinate_no, coordinate_1, coordinate_2 [, norm])

KMeansCentroidND() evaluates the rows of the chart by applying k-means clustering, and for each chart row displays the desired coordinate of the cluster this data point has been assigned to. The columns that are used by the clustering algorithm are determined by the parameters coordinate_1, coordinate_2, etc., up to n columns. These are all aggregations. The number of clusters that are created is determined by the num_clusters parameter.

**KMeansCentroidND**(num_clusters, num_iter, coordinate_no, coordinate_1, coordinate_2 [,coordinate_3 [, ...]])