Knowledge base

Using components: Rank

Use the Rank component to sort the input by one or more field and assign a rank to each record that reflects the sort order that will be available in the component's output. The calculated value is a numeric rank according to the order by which the data is sorted.

If multiple records have the same values in the sort keys (a tie), they will have the same rank value and there will be a gap between them and the next record's rank. To avoid the gap, use the dense option. For example:

sorted field rank dense rank
'a' 1 1
'a' 1 1
'b' 3 2

To define a Rank component:

  1. Add a rank component where required in your package.
  2. Open the component and name it.
  3. In the rank field name, type a name for the field that will contain the rank values.
  4. Select Dense to assign a consecutive value to the next record that follows records with the same rank.
  5. Add the first field you want to sort by, and define the sort order (ascending or descending).
  6. If required, add additional fields to sort by and define their sort order.
  7. Change the field order as required.
  8. Validate the package to make sure that the rank field name is unique.