• Skip to main content
  • Skip to footer

Curbal

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

  • Resources
    • DAX Glossary
    • Download Center
    • Template Apps
    • Data Stories Gallery
    • Solution Gallery
    • Learning Resources
  • Courses
    • Introduction to Power BI – FREE Online course
    • Power Query Online Training for Power BI
    • M Language Online Course: The unofficial and Practical Reference Guide
  • Blog
  • Shop
    • Courses
    • Swag
    • Template Apps
    • Donations
  • Cart
  • Register/ Log In
    • Become a Member
    • Log In
    • My account
    • My Courses
  • 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

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.

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.

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.

Download example file:

Link to demo file here.

 

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?
[Total: 5   Average: 4.6/5]
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 to Heron Cancel reply

Footer CTA

Join our community of +20,000 professionals

Become a Member

Subscribe to YouTube

About us

Curbal AB
Kopparbergsvägen, 10
722 13 – Västerås
Sweden

OrgNo: 5569680852 | VAT: SE556968085201

 

Location:

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