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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Camus
Frequent Visitor

Ranking issue with timeline filters

Hi!

 

I have a list of products that have different categories. I managed to make a formula that rank top products per category ie. every category has the top #1 product sold. Now the issue is that when I add a Year slicer (two years 2016-2017) the rankx formula does not do what I'd like to. When I choose the category from a filter and select only year 2017, the rank values in the table repeat when I choose for example year 2017 only.

Here's the formula for the RANK measure: RANK = IF(ISBLANK('powerBIdata'[Sum of Netsales]);Blank();RANKX(ALL('powerBIdata'[Product]);[KPI];;DESC;Dense))

I'd like to have ranks in normal order that take account the periods I select. Note that the KPI values change correctly with filters

Currently this is what I get:

image.png
I would really appreciate if someone finds some time to help me solve this issue 🙂 

1 ACCEPTED SOLUTION

I think I figured it out! Here's the solution:

RANK = IF(HASONEVALUE(powerBIdata[Category]);rankx(ALL(powerBIdata[Product]);[KPI]))

 

I have to say that DAX is a tricky thing, lots and lots to learn.

 

@TomMartens, Thanks for your attention!

View solution in original post

7 REPLIES 7
TomMartens
Super User
Super User

Hey,

 

put your RANKX() formula inside a CALCULATE() like this CALCULATE(RANKX(...))

 

Hope this solves your issue



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks for the speedy reply, but it did not help. I changed my table to a Matrix, put on a view that also shows categories. What appears to be happening is that the Category itself is ranked aswell. So, obviously the KPI sum of all the categories is higher than any of the products'. So the solutions appears to be to exclude the categories from the Rank calculation. I wonder how to do that... 🙂

Camus
Frequent Visitor

And this means that the issue is not with the time slicers, but how to exclude the categories from the calculation. What is perplexing is that how does the categories get ranked.

Hey,

 

can you please provide a downloadable file with sample data.

 

Regards

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

I think I figured it out! Here's the solution:

RANK = IF(HASONEVALUE(powerBIdata[Category]);rankx(ALL(powerBIdata[Product]);[KPI]))

 

I have to say that DAX is a tricky thing, lots and lots to learn.

 

@TomMartens, Thanks for your attention!

It is 🙂

 

Please mark your post as answer, so others may benefit from your solution.

 

Cheers



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
Camus
Frequent Visitor

OK, What I've noticed is that this might be a Powerbi table issue.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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