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])
| Parameter | Type | Description |
|---|---|---|
| expression | Aggregate / table calculation | The 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
1for the top-ranked valueTied values receive the same rank
Rankings continue sequentially without gaps
Example Output
| Value | RANK_DENSE() |
|---|---|
| 500 | 1 |
| 400 | 2 |
| 400 | 2 |
| 300 | 3 |
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 ofRANK()when gaps are undesirableCombine 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.
It assigns dense ranks to values, ensuring no gaps in ranking numbers.
RANK_DENSE() does not skip ranks after ties, while RANK() does.
Descending order (highest value ranked first).
Yes, it is evaluated after aggregation and depends on the view layout.
Use it when you want clean, consecutive ranking numbers without gaps.