sisense.com
✅ You are viewing documentation for the latest version of Compose SDK.
Version:

Function rank

rank( measure, name?, sort?, rankType?, groupBy?): CalculatedMeasure

Creates a calculated measure that calculates the rank of a value in a list of values.

This function includes options that allow you do customize the ranking order and how to handle equally ranked items.

The order options are:

  • 'DESC' (default): Descending, meaning the largest number is ranked first.
  • 'ASC': Ascending, meaning the smallest number is ranked first.

The rank type options are:

  • '1224': Standard competition, meaning items that rank equally receive the same ranking number, and then a gap is left after the equally ranked items in the ranking numbers.
  • '1334': Modified competition ranking, meaning items that rank equally receive the same ranking number, and a gap is left before the equally ranked items in the ranking numbers.
  • '1223': Dense ranking, meaning items that rank equally receive the same ranking number, and the next items receive the immediately following ranking number.
  • '1234': Ordinal ranking, meaning all items receive distinct ordinal numbers, including items that rank equally. The assignment of distinct ordinal numbers for equal-ranking items is arbitrary.

Parameters

ParameterTypeDescription
measureMeasureMeasure to apply the ranking logic to
name?stringName for the new measure
sort?stringSorting for ranking. By default sort order is descending, where the largest number is ranked first.
rankType?stringHow to handle equally ranked items. By default the type is standard competition ranking.
groupBy?Attribute[]Rank partition attributes

Returns

CalculatedMeasure

A calculated measure instance

Example

Calculate the rank of the total cost per category, sorted with the smallest cost ranked first, and ranking ties are handled using the ordinal ranking type from the Sample Ecommerce data model.

measureFactory.rank(
  measureFactory.sum(DM.Commerce.Cost),
  'Cost Rank',
  measureFactory.RankingSortTypes.Ascending,
  measureFactory.RankingTypes.Ordinal
)

Ranking values from the Sample Ecommerce data model when categorizing by age range using the above ranking.

AgeRangeCostCost Rank
0-184.32M1
19-248.66M2
25-3421.19M6
35-4423.64M7
45-5420.39M5
55-6411.82M3
65+17.26M4
Last Updated: