Tableau Funtion: RANK_DENSE()

Tableau Function: RANK_DENSE( )

Category: Table Calculation Functions

Purpose

The RANK_DENSE() function in Tableau is a table calculation that assigns a dense rank to each row (or mark) within a partition based on a numeric expression. Unlike RANK(), dense ranking does not skip rank values when ties occur.

In simple terms, RANK_DENSE() answers:
“What is this value’s position relative to others, without gaps in ranking?”

Type of Calculations

  • Table calculations

  • Order-based ranking

  • Relative comparison calculations

  • Post-aggregation analytics

RANK_DENSE() is evaluated after aggregation and depends on the view’s sort order and table calculation scope.

Practical Use Cases

  • Creating leaderboards without gaps

  • Ranking products, customers, or regions cleanly

  • Building Top-N dashboards with consistent numbering

  • Applying conditional formatting based on rank

  • Segmenting data into ranked groups


RANK_DENSE(expression, [order])

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

How It Works?

Logical Principle

RANK_DENSE() sorts values within a partition and assigns ranks based on unique sorted values:

Dense Rank = count of distinct values ≥ current value

Key behaviors:

  • Default ranking is descending

  • Ties share the same rank

  • Next rank increases by 1, not by the number of ties

What Does It Return?

  • Data Type: Integer

  • Meaning:

    • Returns 1 for the top-ranked value

    • Tied values receive the same rank

    • Rankings continue sequentially without gaps

Example Output

ValueRANK_DENSE()
5001
4002
4002
3003
 

When Should We Use It?

Use RANK_DENSE() when you need to:

  • Rank data without gaps in numbering

  • Display clean, sequential leaderboard rankings

  • Group values into ranked tiers

  • Avoid confusion caused by skipped ranks

  • Perform consistent Top-N or Bottom-N analysis

Basic Usage

Dense rank values in descending order


RANK_DENSE(SUM([Sales]))

  • Highest value receives rank 1
  • No rank values are skipped

Column Usage

Ascending dense rank


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

Lowest profit receives rank 1

Filter Top 5 dense ranks


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

Always returns exactly 5 ranked positions (if available)

Advanced Usage

Highlight top performers


IF RANK_DENSE(SUM([Sales])) <= 3 THEN "Top 3"
ELSE "Others"
END

Useful for conditional formatting and labeling

Dense rank within partitions


RANK_DENSE(SUM([Sales]))

(with Compute Using set per category)

Ranks independently within each partition

Tips and Tricks

  • Confirm sorting and Compute Using settings

  • Use RANK_DENSE() instead of RANK() when gaps are undesirable

  • Combine with parameters for dynamic Top-N controls

  • Rankings change if sort order changes

  • Not appropriate for row-level calculations

Related Functions

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

  • RANK()

  • RANK_UNIQUE()

  • INDEX()

  • FIRST()

  • LAST()

  • WINDOW_SUM()

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_DENSE() do in Tableau?

It assigns dense ranks to values, ensuring no gaps in ranking numbers.

2. How is RANK_DENSE() different from RANK()?

RANK_DENSE() does not skip ranks after ties, while RANK() does.

3. What is the default sort order for RANK_DENSE()?

Descending order (highest value ranked first).

4. Is RANK_DENSE() a table calculation?

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

5. When should I use RANK_DENSE() instead of RANK()?

Use it when you want clean, consecutive ranking numbers without gaps.