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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
poojithas
Helper III
Helper III

Incorrect Ranking using RANKX

Hi All,

I have a requirement to show top 20 values in a table.

For that I have used RANKX function. Code below.

 

poojithas_6-1680495037427.png

This gives me the correct ranking based on the field volume. 

poojithas_8-1680495540048.png

 

But, after I apply Top 20 filter, the ranking is incorrect. The Ranks are repeated and the values are not in the expected order. 

 

poojithas_7-1680495456332.png

This is happening due to the RL12 filter.

poojithas_0-1680507033861.png

 

 I am only including data where RL12="Y". So, whereever there are no records for RL12=Y, the rank is getting skipped.

Could someone please suggest on how this can be fixed and show all the ranks in order without any repetition.

Thank you

Poojitha

 

 

 

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @poojithas ,

 

You can change All() to the AllSelected() function.

ALLSELECTED function (DAX) - DAX | Microsoft Learn

The ALLSELECTED function gets the context that represents all rows and columns in the query, while keeping explicit filters and contexts other than row and column filters. 

If the display is still incorrect,  can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data. We can better understand the problem and help you.

 

Best Regards,

Liu Yang

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

@v-yangliu-msft  : I have used ALLSELECTED and the output is still incorrect. 
There was a visual filter for the field "Type" where the logic was concatenate(comments,ntn/non-ntn) and this had the output as below: I was restricting this to only show Regular NTN and Premium NTN.

Regular NTN
Regular Non-NTN
PremiumI NTN
Premium Non-NTN
Non-Premium NTN
Non-Premium Non-NTN

I created another column with the logic as if type=Regular NTN and Premium NTN then include else exclude. I used this field instead of TYPE in the visual filter. This fixed the issue with Ranking.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors