• Skip to main content
  • Skip to footer

Curbal

Learn how to grow your business with your data and Power BI

  • Data Stories
    • Power BI Stories
    • 1 dataset, 100 matplotlib visualizations
  • Learning Portal
    • Download Center
    • 25 Days Challenge
    • DAX Glossary
    • Power BI
    • Power BI by Topic
    • Python
    • 1 dataset, 100 matplotlib visualizations
  • Courses
    • Power BI Mini Master Class 1: Using a REST API as a data source
    • Power BI Master Class 1: COVID Tracker
    • Introduction to Power BI – FREE Online course
    • M Language + Power Query Course Bundle
    • Power Query Online Training [updated 2022]
    • M Language Online Course: The unofficial and Practical Reference Guide [updated 2025]
    • My Courses
  • Shop
    • Courses
    • Master Classes
    • Template Apps
    • JSON Themes
  • Cart
  • Register/ Log In
    • Become a Member
    • Log In
    • My account
    • My Courses
  • Search
  • Contact
You are here: Home / CM Tooltip Glossary Pro+ / RANKX

RANKX

posted on August 15, 2017

« Back to Glossary Index

Syntax

RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]])

Tutorial with example

Learn how to use the DAX RANKX() function to arrange your data based on criteria that you specify.
Keynotes:
– Rankx on categories 03:00
– Rank ascending 03:17
– Rank with allselected 03:35
– Rank with blanks 05:28
– Rank on products 07:26
– Rank with column 10:50

DAX Fridays! #9: RANKX DAX Function

Exercise2: Rank with a slicer

In this video you will learn how to create a custom slicer that will rank your data based on the criteria that you specify, for example, Top 3, Top 5 and Top 10.

DAX Fridays! #10: RANK/ TOPN with slicer

Exercise 3: Break Rank ties

In this video I will show you how DAX RAND function works and also how to use it to break ties on the RANKX calculation to be able to create TOP X lists in Power BI.

DAX Fridays! #26: Break RANKX ties with RAND()

Exercise 4: Dynamic TopN+Others

In this video we will use the dax function RANKX to create a dynamic TOP N elements and categorize the rest as others.

DAX Fridays! #132: Dynamic TopN + Others in Power BI

Download example file:

To get the files:
1. Go to Curbal Download Center > Dax Fridays
2. Get File #132

Remarks

  • If expression or value evaluates to BLANK it is treated as a 0 (zero) for all expressions that result in a number, or as an empty text for all text expressions.
  • If value is not among all possible values of expression then RANKX temporarily adds value to the values from expression and re-evaluates RANKX to determine the proper rank of value.
  • Optional arguments might be skipped by placing an empty comma (,) in the argument list, i.e. RANKX(Inventory, [InventoryCost],,,”Dense”)
Was this helpful?
See Also:
  • RAND
« Back to Index

Reader Interactions

Comments

  1. sdharmas

    September 3, 2018 at 12:40 am

    Hi Ruth, I couldn’t download the example files. Get error messages like the following:
    The webpage at https://degofile.re.cs.quickconnect.to/2kEOD/sharing/wC7Ep6s6w?tunnel=/tunnel/ might be temporarily down or it may have moved permanently to a new web address.

    Can you post where the example files are located?

    Your videos are awesome. So well constructed and your explanations are great. Keep adding more content.

    Reply
    • Ruth Pozuelo Martinez

      September 6, 2018 at 11:08 am

      All the links are working for me, can you try again with another browser? I need to move my download files somewhere else…
      /Ruth

      Reply
      • Heron

        October 11, 2018 at 1:20 am

        Hello Ruth, unfortunately , I couldn’t download the example files too, the link didn´t works

        Reply
      • Reza

        October 23, 2018 at 2:34 pm

        I have a table with Store ID, Store Name and Sales.

        I have created a measure to Rank the Store Names based on highest sales.

        StoreRank = RANKX(ALLSELECTED(
        ‘Table'[Store Name]),
        CALCULATE(SUM(‘Table'[Sales])),,DESC)

        When I use the Rank alone with Store Name it works, but the moment I add store ID in the it returns all ranks to – 1

        Reply
        • Ruth Pozuelo Martinez

          October 24, 2018 at 9:57 am

          Hi,
          Could you please post the question in the power bi community? Thanks!

          Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer CTA

Join our community of +50,000 professionals

Become a Member

Subscribe to YouTube

About me:

Curbal AB
Badhusgatan 7B
722 15 – Västerås
Sweden

OrgNo: 5569680852 | VAT: SE556968085201

 

Location:

© Copyright 2014-2025 · Curbal AB · All Rights Reserved · Privacy Policy · Terms of Service · Refund Policy · Log In