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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.