Shape · Rows

Rank

Ranks rows by one or more columns, optionally within groups, so the top seller per region gets 1. You choose how ties are ranked; percentile rank is available too, and Tile splits the rows into N equal-sized buckets.

Also known as: Dense rank, percentile

How it works

Group by restarts the ranking for each group. Order by lists the keys the rank follows, each with a Direction of Asc or Desc and Nulls First or Last. Method decides ties: Average, Min and Max give tied rows the same number, First numbers them by row order, Dense leaves no gaps after a tie, and Tile (equal count) puts the rows into Tiles buckets of equal size, 5 by default, in row order when Order by is empty. Output column defaults to <column>_rank or <column>_tile. Percentile [0, 1] replaces the rank with a percentile for every method except Tile. For Dense, Order ids by chooses Sorted key value or First appearance, which numbers each distinct key in the order it first shows up, and Start at and Step let Dense and Tile ids begin anywhere and count in steps.

Inputs and outputs

Inputs

  • data — Table

Outputs

  • data — Table

Settings

The Attributes panel of Rank, as in the app: the controls work, but nothing runs — there is no data behind it.

The same settings, as the Assistant writes them
{
  orderBy: [{ column: string, direction: "asc"|"desc", nulls: "first"|"last" }]
  method: "average"|"min"|"max"|"first"|"dense"|"tile"
  groupBy?: string[]
  outputColumn?: string
  pct: boolean
  idOrder?: "value"|"appearance" (dense: ids by sorted key or by first appearance)
  tiles?: number (tile: bucket count, default 5; orderBy may be empty = row order)
  from?: number
  step?: number (dense/tile ids = from + (n - 1) * step, default 1/1)
}

Example

The top seller in each region gets 1: Order by sales Descending, Method Min, Group by region. Two sellers tied for first both get 1 and the next gets 3; with Dense the next would get 2.