Tableau Funtion: RANK_UNIQUE( )

Tableau Function: RANK_UNIQUE( )

Category: Table Calculation Functions

Purpose

The RANK_UNIQUE() function in Tableau is a table calculation that assigns a unique rank value to every row (or mark) within a partition. Unlike other ranking functions, no two rows ever share the same rank, even when values are tied.

In simple terms, RANK_UNIQUE() answers:
“What is the unique position of this row when ties must be broken?”

Type of Calculations

  • Table calculations

  • Order-based unique ranking

  • Tie-breaking calculations

  • Post-aggregation analytics

RANK_UNIQUE() is evaluated after aggregation and depends on the sort order and table calculation scope.

Practical Use Cases

  • Creating strict leaderboards with no tied positions

  • Generating unique row numbers based on value order

  • Ensuring deterministic Top-N results when ties exist

  • Supporting downstream calculations that require unique ranks

  • Breaking ties automatically without additional logic


RANK_UNIQUE(expression, [order])

ParameterTypeDescription
expressionAggregate / table calculationThe numeric value to rank. Must be aggregated in the view.
order (optional)Scalar (string)Sort direction: "asc" for ascending or "desc" for descending. Default is "desc".

How It Works?

Logical Principle

RANK_UNIQUE() sorts values within a partition and assigns a distinct rank to each row, even when values are identical:

 
Unique Rank = sequential row position after sorting

Key behaviors:

  • Default sort order is descending

  • Ties are resolved automatically

  • Rank values are never duplicated

Comparison with Other Ranking Functions

FunctionTies Share RankRank GapsUnique Ranks
RANK()YesYesNo
RANK_DENSE()YesNoNo
RANK_MODIFIED()YesMinimalNo
RANK_UNIQUE()NoNoYes

What Does It Return?

  • Data Type: Integer

  • Meaning:

    • Returns a unique rank for every row

    • No two rows share the same rank

    • Rank values increase sequentially

Example Output

ValueRANK_UNIQUE()
5001
4002
4003
3004

When Should We Use It?

Use RANK_UNIQUE() when you need to:

  • Eliminate ties completely

  • Guarantee unique rank values

  • Create deterministic Top-N lists

  • Assign row-level ranking IDs

  • Support calculations requiring unique ordering

Basic Usage

Assign unique ranks


RANK_UNIQUE(SUM([Sales]))

  • Every row receives a distinct rank
  • Highest value ranked first by default

Column Usage

Ascending unique rank


RANK_UNIQUE(SUM([Profit]), "asc")

Lowest profit receives rank 1

Filter Top 5 unique values


RANK_UNIQUE(SUM([Sales])) <= 5

Ensures exactly 5 rows are returned (if available)

Advanced Usage

Tie-breaking without secondary sort


RANK_UNIQUE(SUM([Sales]))

Automatically breaks ties without additional logic

Unique ranking within partitions


RANK_UNIQUE(SUM([Sales]))

(with Compute Using set per Category)

Ensures unique ranks inside each partition

Tips and Tricks

  • Use when ties must be eliminated

  • Confirm sorting and Compute Using

  • Useful for deterministic filtering

  •  Tie-breaking order may not be obvious to users

  • Avoid when shared ranks are semantically meaningful

Related Functions

Functions commonly used alongside or as alternatives to RANK_UNIQUE():

  • RANK()

  • RANK_DENSE()

  • RANK_MODIFIED()

  • RANK_PERCENTILE()

  • INDEX()

  • FIRST()

We’ve got plenty of resources to help you master Tableau functions. For more details, check out the official Tableau documentation. Or, if you’re ready for more practice, let’s dive into related functions and build your Tableau skills further!

If you’re ready to harness the full power of Tableau and elevate your data analytics capabilities, our expert Tableau consulting services are here to guide you. Whether you need support with building advanced calculated fields, creating dynamic visual dashboards, or optimizing your data sources for peak performance, our team of experienced Tableau consultants delivers customized solutions designed for your business needs. Visit our Tableau Consulting page to discover how we can help your organization turn data into impactful, insight-driven decisions.

1. What does RANK_UNIQUE() do in Tableau?

It assigns a unique rank to every row, even when values are tied.

2. How does RANK_UNIQUE() handle ties?

Ties are automatically broken so that no two rows share the same rank.

3. Is RANK_UNIQUE() deterministic?

Yes, but the tie-breaking order depends on the view’s internal row order.

4. Is RANK_UNIQUE() a table calculation?

Yes, it is evaluated after aggregation and depends on the view layout.

5. When should I use RANK_UNIQUE()?

Use it when rankings must be strictly unique with no shared positions.