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
Stringer8487
Regular Visitor

Trouble writing RankX measure with slicers

Hey everyone, 

 

First time posting so forgive me if this is a topic covered in depth or if it is a really stupid question. Did searching and tried applying some solutions and nothing was making sense.

 

So I have 5 categories in my data set that I would like ranked dynamically based on what items I have selected via slicer. Example, if category A is selected, I get a rank of all the items in category A. (I have some more complex ideas like breaking it down by subcategory as well within a column but that feels like it's way beyond my grasp at this point)

 

I've been trying to use some simple RankX measures ala

 

Rank = RANKX(ALLSELECTED('TABLE' [Category1]),CALCULATE(SUM('TABLE'[Category2]) ) )

 

And been getting tables with simply a 1 as a rank that doesn't change even if I apply different categories.

 

When I was trying to do more simple ones like 

 

Rank = RANKX('TABLE','TABLE'[Category1],,ASC) 

 

I was getting nothing but error messages about not enough arguments, or too many arguments in some cases.

 

I know I am not understanding how the line of logic and code works to get what I need, so I was wondering if anyone could help me out in setting me on my way to understanding, or at least had a helpful tip or teaching article I could read to get going in the right direction.

 

Thanks

 

5 REPLIES 5
v-yuezhe-msft
Employee
Employee

@Stringer8487,

Please check if DAX in the attached PBIX file returns your expected result. If not, please share sample data of your table and post desired result here.

Regards,
Lydia

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

Wow, okay this REALLY helped. Got me part of the way there. Here is what I am running into now.

 

So let's give better examples. I wanna do the sprint times of individual runners in groups A, B, and C, and in the races 100M, 200M, and 300M, and see the rank of who is the fastest based on the slicers being selected (Runner, Group, Race). Not single select either. So group A and B or groups B and C, in the 200, but also runner 1, 2, 3 in Group A. 

 

That measure got me part of the way there in terms of a rank being created for the times, but it's spitting out the rank for the groups as one average. So it's combining the individual run times of multiple runners when I multiselect them into one value instead of rankings the runners individually. I've messed around a little with it and got it to the point of it ranking the average of the race times of all the runners combined.

 

I know this is a lot to ask for a dynamic ranking like this, and I wish I could share screenshots, but my company data and privacy policy is...well, you know how it goes.

 

That example before was awesome though, got me part of the way!! Thank you!!! 

@Stringer8487,

Please share dummy data of your table here which I can copy and paste, and post expected result based on the data you share.

Regards,
Lydia

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

Runner Group Race Time

Runner A150m 
Runner B1100m 
Runner C2100m 
Runner D2100m 
Runner F350m 

 

Okay so there is a basic table that I would have set up in theory (Times can be whatever you like, made up if you want or just use a round number)

 

So I would concievably like a dynamic ranking that allows me to rank within each group and each race and together. So Runner A can be ranked by himself in group 1 of the 50 m, but also when selected against Runner F in group 3. Runner C and D can go head to head in group 2, but also against the time of Runner B when group 1 is included. 

 

Hope that helps!

@Stringer8487,

Could you please share expected result based on the above sample data in table format?

Regards,
Lydia

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

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.