skip to main content
Power BI
    • What is Power BI
    • Why Power BI
    • Customer stories
    • Data visuals
    • Security
    • Power BI Desktop
    • Power BI Pro
    • Power BI Premium
    • Power BI Mobile
    • Power BI Embedded
    • Power BI Report Server
  • Pricing
    • Azure + Power BI
    • Microsoft 365 + Power BI
    • Dynamics 365 + Power BI
      • Energy
      • Healthcare
      • Manufacturing
      • Media
      • Retail
    • For analysts
    • For IT
      • Overview
      • Embedded analytics
      • Power BI visuals
      • Automation
      • Documentation
      • Community
    • Overview
    • Find consulting services
    • Partner showcase
    • Find a partner
    • Become a partner
    • Instructor-led training
    • Getting started
      • Overview
      • Online workshops
      • Self-guided learning
      • Webinars
      • Documentation
      • Roadmap
      • Overview
      • Issues
      • Give feedback
    • Blog
    • Business intelligence topics
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • Events
    • User groups
    • Community blog
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Galleries
    • Community Connections & How-To Videos
    • COVID-19 Data Stories Gallery
    • Themes Gallery
    • Data Stories Gallery
    • R Script Showcase
    • Webinars and Video Gallery
    • Quick Measures Gallery
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Events
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power BI Community
    • Galleries
    • Quick Measures Gallery
    • Ranking

    Ranking

    04-25-2017 19:37 PM - last edited 04-25-2017 19:37 PM

    Super User GilbertQ
    Super User
    6275 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    GilbertQ
    Super User GilbertQ
    Super User
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    Ranking

    ‎04-25-2017 07:37 PM

    This is a simple measure but one that I have used countless times for ranking of products or in this example Surfers and their prize money.

     

    This rank can also be used in conjunction with the TOPN or BOTTOMN filters 

     

    NAME:

    Rank per category

     

    DESCRIPTION:

    Calculate the rank of the base value within the category

     

    PARAMETERS:

    Name: Base value

    Tooltip: The value you want to average

    Type: Numerical field / measure

     

    Name: Category

    Tooltip: The category in which you want to calculate the rank

    Type: Categorical field

     

    DAX:

    Rank {Base value} per {Category} =

    RANKX(

      ALLSELECTED({Category}),

      {Base value}

    )

     

     

    eyJrIjoiYTRkN2VhYmEtY2U1OS00Nzg0LThiODgtZDZhYTdlYWY2MTQ4IiwidCI6ImQ3MGI0ZDU1LWE1OTItNDVmMi05OWYzLTI5OWFlNWVlN2FkZSJ9





    Did I answer your question? Mark my post as a solution!

    Proud to be a Super User!







    Power BI Blog

    Preview file
    17 KB
    Power BI - Quick Measures - RANKX.pbix
    Labels:
    • Labels:
    • Other
    Message 1 of 4
    6,275 Views
    2
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic
    Quentin
    Quentin Helper III
    Helper III
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-21-2020 01:52 AM

    Thank you for sharing! 🙂 

    I'm facing this issue that when someone select a surfer, it filters the table and take the filtered table in the DAX measure. THerefore selecting a surfer always show of ranking of 1 while it could be more interested to see the ranking in the overall table.

    I think something can be done using All instead of Allselected in the formule 

     

    Regards,

    Message 3 of 4
    1,254 Views
    0
    Reply
    GilbertQ
    Super User GilbertQ
    Super User
    In response to Quentin
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎08-23-2020 05:42 PM
    Hi there that is correct, if you had to use the ALL it would keep the ranking no matter what you selected.




    Did I answer your question? Mark my post as a solution!

    Proud to be a Super User!







    Power BI Blog

    Message 4 of 4
    1,188 Views
    0
    Reply
    alissa
    alissa
    Frequent Visitor
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    ‎06-14-2019 01:43 PM

    This is awesome, and so streamlined! Could one use similar code to calculate a percentile (like PERCENTRANK in Excel)? What would that look like? I've been trying to implement something like this with DAX and it's becoming way too memory intensive.

    Message 2 of 4
    2,057 Views
    0
    Reply

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign in
    • Sign up

    Browse

    • Solutions
    • Partners
    • Consulting Services

    Downloads

    • Power BI Desktop
    • Power BI Mobile
    • Power BI Report Server
    • See all downloads

    Learn

    • Guided learning
    • Documentation
    • Support
    • Community
    • Give feedback
    • Webinars
    • Developers
    • Blog
    • Newsletter

    © 2023 Microsoft

    Follow Power BI

    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Trademarks
    California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices