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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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