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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jayt93
Frequent Visitor

RankX Duplicates when multiple slicer filter selected

Hi everyone,

 

I've been trying to figure this one out for a while but couldn't come up with a solution.

I have a slicer for a Category and Year among a few others.

 

I have a table visual that shows the following:

Item IDItem DescriptionPriceRankPrior Yr PricePrior Yr Rank
001ABC501481
002BCD452403
003CDE403452
004EFG354275
005FGH305304

 

This works perfectly fine when one of the the categories is selected OR if all the categories are selected but not when a mix of them are selected (For example, only Category A & Category C). In those cases duplicates ranks would show up and it seems like it's evaluating the rank for each item based on the Category individually rather than together.

 

This is how I was calculating the prior year rank:

Prior Yr Rank = 

var py_table = filter(ALLEXCEPT(Table, Table[Categories]),Table[Year]=MAX(Table[Year])-1)
var py_filter = filter(ALLEXCEPT(Table, Table[Categories], Table[Item ID]),Table[Year]=MAX(Table[Year])-1)
return
rankx(py_table, CALCULATE(SUM(Table[Price],py_filter))
 
Any help would be greatly appreciated.
1 ACCEPTED SOLUTION

Thank you @lbendlin.

 

@jayt93 - please find attached the PBI file.  Had to make a lot of changes in there.  Please review the file carefully.

Ashish_Mathur_0-1708918424234.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

9 REPLIES 9
jayt93
Frequent Visitor

@Ashish_Mathur @lbendlin 

My apologies I should have attached a sample data set.

In the sample file this is what I'm trying to achieve:

jayt93_0-1708884662310.png

Any help would be greatly appreciated, thanks!

Hi,

When i click on Download, I am take to a sign-in or sign-up page.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur see attached

Thank you @lbendlin.

 

@jayt93 - please find attached the PBI file.  Had to make a lot of changes in there.  Please review the file carefully.

Ashish_Mathur_0-1708918424234.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Amazing, thank you Ashish! I will try applying this to my actual data set. I didn't even think of creating another date table for this. Just out of curiosity is it not possible to achieve the same result without creating a date table?

You are welcome.  Even if it is, i would not try it.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@lbendlin Thank you so much I was just trying to figure out how to upload it here!

Ashish_Mathur
Super User
Super User

Hi,

Share data in a format that can be pasted in an MS Excel file and show the expected result clearly.  Also, clarify the result if there are ties - show that in the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Do you want to keep the rank even if you change the filter context?  Did you use calculated columns or measures?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.