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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
powerbidev123
Responsive Resident
Responsive Resident

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
New Member

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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