Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Vish24
Helper II
Helper II

Ranking based on measure

Hello,

 

I am trying to do the ranking for sales by people in regions. I am getting correct result if I am showing in table. But I want to make a slicer for a sales persons names and then show the ranking of the selected person . I am getting one in ranking for each person. Its giving me correct result if I am making a table with names and rank.

 

Please 

1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Vish24 ,

 

At first, you need to add an index coloumn in the query editor.

Then refer to the following measure:

Measure =
MINX (
    FILTER (
        SELECTCOLUMNS (
            ALLSELECTED ( 'Table' ),
            "index", 'Table'[Index],
            "rank", RANKX ( ALLSELECTED ( 'Table' ), 'Table'[Column2],, DESC, DENSE )
        ),
        [index] = MAX ( 'Table'[Index] )
    ),
    [rank]
)

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

4 REPLIES 4
v-eachen-msft
Community Support
Community Support

Hi @Vish24 ,

 

At first, you need to add an index coloumn in the query editor.

Then refer to the following measure:

Measure =
MINX (
    FILTER (
        SELECTCOLUMNS (
            ALLSELECTED ( 'Table' ),
            "index", 'Table'[Index],
            "rank", RANKX ( ALLSELECTED ( 'Table' ), 'Table'[Column2],, DESC, DENSE )
        ),
        [index] = MAX ( 'Table'[Index] )
    ),
    [rank]
)

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
JarroVGIT
Resident Rockstar
Resident Rockstar

In your measure, change RANKX(<table>.... to RANKX(ALL(<Table>)... 

This is likely to solve your case, depending on your datamodel. Otherwise your measure would be something like this:

RankingMeasure = 
VAR _tmpTable = SUMMARIZE(Sales, Sales[SalesPerson], "totalSales", SUM(Sales[Amount]))
VAR _rankedTable = ADDCOLUMNS(_tmpTable, "rank", RANKX(_tmpTable, [totalSales], , DESC)
VAR _curSalesPerson = SELECTEDVALUE(Sales[SalesPerson])
RETURN
MAXX(FILTER(_rankedTable, [SalesPerson] = _curSalesPerson), [rank])

This is without any intellisense so forgive any errors or typos but is does illustrate the required logic 🙂 Let me know if this helps you!

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





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

Proud to be a Super User!




amitchandak
Super User
Super User

Refer this :https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures

Also in this blog, I filter on top brand. Refer :Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I want to show the ranking only for the selected person. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.