[Power BI] DAX ALL Function Practical Series ② Mastering Ranking (Ranking Analysis, Top-N, Pareto Analysis) - Part 1


In Power BI, ranking analysis goes beyond simple data sorting; it is a vital method for understanding market structures. While a simple sales report focuses on the past record of "how much was sold," ranking analysis answers more critical questions:
  • Which of our products is the number one bestseller?
  • What percentage of total sales do the top 20% of products generate?
  • How much has this month's rank changed compared to last month?
  • How does the ranking of popular products differ from store to store?
To answer these questions, you must use the RANKX function in conjunction with the ALL function. The ALL function plays an especially crucial role in ranking analysis because it restores data hidden by filters, creating a "complete competitive landscape that includes invisible competitors."

Power BI Ranking Analysis Series

This series consists of five practical analysis parts:
  • Part 1 — Global Ranking (RANKX + ALL) -- Current Post
  • Part 2 — Top-N & Others (Pareto)
  • Part 3 — Relative Rank Index
  • Part 4 — Cross Ranking (Store × Product)
  • Part 5 — Rank Change Analysis


In this series, our goal is not just to explain DAX, but to fully understand Power BI ranking analysis by connecting DAX Design → Actual Data Calculation → Strategic Interpretation.

What We Will Cover in This Post

In this first session, we will focus on the mechanisms of the RANKX and ALL functions, which are the core of calculating company-wide rankings.
  • Why Ranking Analysis is Important
  • The Structure of the Power BI RANKX Function
  • Why the ALL Function is Necessary for Ranking
  • Product Ranking Analysis Calculated with Actual Data



 

1. Why is Ranking Analysis Important?

1.1 Ranking Enables Strategic Judgment 

In the previous post, we used Mix & Share analysis to see "who occupies how much of the total sales." However, in actual strategic decision-making, the following question is more important: "So, who is number one?"
While share analysis explains the market structure, ranking analysis shows the competitive landscape. In practice, ranking analysis is utilized in the following situations:
  • Resource Allocation: Do the top 20% of products (Top-N) generate 80% of total sales?
  • Performance Evaluation: What is the rank of this store compared to the company average?
  • Spotting Trends: Did a product that was 5th last month rise to 2nd this month?

1.2 Analysis Data Overview: H1 2024 IT Device Sales

  • Stores: New York (NY), Los Angeles (LA), Chicago, Houston
  • Products: iPhone 15, MacBook Air, Galaxy S24, Pixel 8, Surface Pro

Sales monthly table by store

  • Total Sales

= SUMX(Sales, Sales[SalesAmount])
2,114,000 USD
  • Store Sales Structure:
Store Sales Structure


 

2. The RANKX Function


2.1 Basic Structure of Power BI RANKX

RANKX(Table, Expression, [Value], [Order], [Ties])

RANKX Function

Table: "Who are you comparing against?" (ALL, VALUES, ALLSELECTED)
  • Expression: "What is the criteria for lining them up?" (e.g., [Total Sales])
  • Order: DESC (Descending) or ASC (Ascending).
  • Ties: Skip (1, 1, 3...) or Dense (1, 1, 2...).

static global ranking (All) vs. Dynamic interactive ranking (allselcted)

2.2 Pro Tip: Catching Both Performance and Readability

  • Minimize Filter Scope: Use ALL('Sales'[Product]) instead of ALL(Table).
  • Use Measures: Reference pre-made measures for faster caching.
  • Utilize ISINSCOPE: Use IF(ISINSCOPE('Sales'[Product]), [Rank], BLANK()) to hide ranks in the Total row.

(Global Rank)

    Rank (ALL) =
        IF (
            ISINSCOPE('Sales'[Product]),
            RANKX(
                ALL('Sales'[Product]),
                [Total Sales],
                ,    
                DESC,
                Skip
                ),
                BLANK()
                )


 

3. Why is the ALL Function Essential for Ranking?


3.1 Without ALL vs. With ALL: The Difference in Comparison Sets 

Ranking is essentially comparing 'me' with 'others.' If the others disappear due to filters, the rank loses its meaning.

Local rank vs. Global rank

  • Without ALL: Compares only visible data (Local Rank).
  • With ALL: Restores hidden data for comparison (Global Rank).

Without all (values) vs. with all (all)

3.2 Verifying the Need for ALL with Data 

Let's look at the difference when only iPhone 15 and Pixel 8 are selected:

1) VALUES Method: Relative comparison within the current filtered range.


    RANKX(
        VALUES('Sales'[Product]),
-- [Arg1] Targets only currently visible products
        [Total Sales], -- [Arg2] Based on Total Sales measure
        , -- [Arg3] Empty (Default)

        DESC, -- [Arg4] Sort descending (High to Low)
            Skip -- [Arg5] Skip next rank if tied (1, 2, 2, 4...)
            )

2) ALLSELECTED Method: Interactive relative rank.


    Rank (ALLSELECTED) =
    RANKX(
        ALLSELECTED('Sales'[Product]),
-- Considers all products currently selected by slicers
        [Total Sales], , DESC, Skip
        )

3) ALL Method: Absolute comparison ignoring filters.


Rank (ALL) =
        RANKX(
        ALL('Sales'[Product]),
-- [Arg1] Removes filters to provide the full list
        [Total Sales], , DESC, Skip
        )

4) ALL vs VALUES vs ALLSELECTED (Critical Comparison)

ALL vs VALUES vs ALLSELECTED
  • VALUES: Both products appear as #1. This is the "Filter Trap" where each row is isolated and compared only to itself.
  • ALLSELECTED: Displays Pixel 8 as #2. It considers all items currently selected by the user. Best for interactive dashboards.
  • ALL: Displays Pixel 8 as #4. It ignores filters and restores products not on the screen to show the true market position.
Product ranking


 

4. Product Ranking Analysis

Rankings based on the total sales of 2,114,000 USD:
  • 1st - iPhone 15: 685,000 USD (32.4% Share)
  • 2nd - MacBook Air: 605,000 USD (28.6% Share)
  • 3rd - Galaxy S24: 390,000 USD (18.4% Share)
  • 4th - Pixel 8: 297,000 USD (14.0% Share)
  • 5th - Surface Pro: 137,000 USD (6.5% Share)

4.1 Strategic Positioning by Product


1) 1st Place — iPhone 15: Absolute Market Dominance (Market Leader)

An unrivaled product responsible for 32.4% of sales as a single SKU. Unlike general structures where multiple products disperse sales, this shows a clear leader.
  • Strategy: A premium strategy that maintains brand value rather than price competition is appropriate.
  • Action: Maximize Average Revenue Per User (ARPU) through high-priced accessory bundling and AppleCare service expansion.

2) 2nd Place — MacBook Air: Core Revenue Pillar (Core Driver)

A practical pillar of sales with only about an $80,000 gap from 1st place.
  • Strategy: This is the zone where cross-selling with the iPhone is most effective.
  • Action: Expand the ecosystem through "Apple Ecosystem Package" configurations and back-to-school promotions for university students.

3) 3rd & 4th Place — Android Camp: Stable Chasers (Challenger)

Galaxy S24 and Pixel 8 form a middle group with a significant sales gap from the leaders.
  • Strategy: A value strategy is needed to absorb price-sensitive consumers.
  • Action: Remove initial purchase barriers through active trade-in programs and carrier-bundled discounts.

4) 5th Place — Surface Pro: Niche Player


It is difficult to overcome a sales gap of more than 5 times with a mass-market strategy.
  • Strategy: A segment strategy focusing on specific customer groups is efficient.
  • Action: Emphasize professionalism through corporate workflow solutions and marketing targeted at professional designers.

4.2 Core Insights from the Data

The most noteworthy figure in this analysis is 61% (Combined sales of iPhone and MacBook: 1,290,000 USD). The market is moving in units of "Ecosystems" rather than competition between individual products. Features like AirDrop and iCloud create a lock-in effect, acting as a strategic advantage that keeps customers within the ecosystem.
  • Apple Products: Strategy centered on bundling and services emphasizing ecosystem connectivity.
  • Android Products: Strategy centered on price and trade-ins to supplement brand power.
  • Other Products: Niche market marketing strategies targeting specific audiences rather than mass-media advertising.

The true value of ranking analysis lies in giving answers to "where to concentrate resources and in what landscape to fight," going beyond "how much was sold."



 

What's Next ?

"Top-N and Others Visualization Techniques"

In the next post, we will learn how to highlight the Top 1-5 (Top-N) while grouping the rest as 'Others' using dynamic DAX grouping and Pareto analysis. Reading the world through data—to be continued in the next episode.

Found this helpful? Let me know with a like or a quick comment! If you’re stuck on the DAX or need more clarity on the results, just leave a note below. I’d be happy to dive back in with you.



Comments

Popular posts from this blog

DAX CALENDAR Function Deep Dive and Practical Usage Guide

Standard Deviation (Part 2): Strategic Limitations and Complementary Perspectives in Standard Deviation Analysis

Standard Deviation (Part 1): Measuring Data Volatility and Using the Insights for Better Strategy