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
webportal
Impactful Individual
Impactful Individual

RANKX in table and slicers

This is table Fact:

Date               Person Place     Status       Sales

01/01/2020ABCNorthActive9852
14/01/2020DEFNorthActive3452
17/01/2020GHINorthActive9084
02/02/2020GHINorthActive4902
14/02/2020GHINorthActive4659
14/02/2020DEFSouthInactive5000
23/02/2020GHINorthActive1685
10/03/2020GHINorthActive6401
21/03/2020ABCCenterActive4742
09/04/2020ABCCenterActive6325
14/04/2020ABCCenterActive8329
27/04/2020ABCCenterInactive7740
28/04/2020ABCCenterInactive5091
02/05/2020ABCCenterInactive3763
04/05/2020ABCCenterInactive1434
06/05/2020DEFCenterActive3718
22/05/2020DEFSouthActive6639
03/06/2020DEFSouthActive5672
12/06/2020DEFSouthActive5268
16/06/2020DEFSouthActive3358

 

I want to calculate the ranking of sales, depending on slicers for dimensions date, person, status and place.

 

So:

 

This measure: 

TotalSales = SUM('Fact'[Sales])
 
Gives me the to total sales.
 
And:
 
This measure:
Ranking =
IF([TotalSales],
RANKX (
ALLSELECTED ('Fact'),
CALCULATE ( [TotalSales] ),
,
DESC,
DENSE
))
 
Is supposed to give me the ranking.
 
And it does, if all the dimensions are in:
 
Anotação 2020-08-11 171349.jpg
 
However, if I remove the date:
Anotação 2020-08-11 171506.jpg
 
This is non-sense. Can anyone help calculating the rank? Thanks 
1 ACCEPTED SOLUTION

hi  @webportal 

You need to create different measure for different visual that have different row context

Ranking 2 = 
IF([TotalSales],
RANKX (
ALLSELECTED ('Fact'[Person],'Fact'[Place],'Fact'[Status]),
CALCULATE ( [TotalSales] ),
,
DESC,
DENSE
))

Result:

3.JPG

 

Regards,

Lin

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

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@webportal , measure rank is context-sensitive(Display). When you took ALLSELECTED ('Fact'), it means Rank will create at the lowest level of fact, any change in that will not give you correct rank

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Sure, I know that, but how to solve the problem?

PS: Why are my posts being translated into Spanish?

@webportal @v-lili6-msft my posts have been getting translated into Spanish too!





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

Proud to be a Super User!




webportal
Impactful Individual
Impactful Individual

@amitchandak are you still there, can you help?

hi  @webportal 

You need to create different measure for different visual that have different row context

Ranking 2 = 
IF([TotalSales],
RANKX (
ALLSELECTED ('Fact'[Person],'Fact'[Place],'Fact'[Status]),
CALCULATE ( [TotalSales] ),
,
DESC,
DENSE
))

Result:

3.JPG

 

Regards,

Lin

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

Helpful resources

Announcements
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!