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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
powerbidev123
Solution Sage
Solution Sage

Rankx is not working

Hi Community,

 

 

The Rankx function doesnt seem to work. Below is the screenshot.

 

Can anyone please help what wrong am I doing here

 

powerbidev123_0-1734433168532.png

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You need to use CALCULATE to force context transition

Ranking Sales =
RANKX (
    ALL ( Orders[Row ID], Orders[Sales] ),
    CALCULATE ( SUM ( Orders[Sales] ) ),
    ,
    DESC,
    DENSE
)

View solution in original post

3 REPLIES 3
madP
Regular Visitor

Create a measure 

revenue = SUM('Table'[sales])
and add new column as below
Ranking_Sales = RANKX(ALL('Table'[RowID],'Table'[sales]), CALCULATE('Table'[revenue]), ,DESCDense)
johnt75
Super User
Super User

You need to use CALCULATE to force context transition

Ranking Sales =
RANKX (
    ALL ( Orders[Row ID], Orders[Sales] ),
    CALCULATE ( SUM ( Orders[Sales] ) ),
    ,
    DESC,
    DENSE
)
vivek31
Resolver II
Resolver II

Hi @powerbidev123 ,

first you can create mesure of total_sales

revenue = SUM(Sales[SalesAmount])

 

and after you can create rankx measure and use ALL(sales) table.

vivek31_0-1734436064511.png

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.