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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Rank with filters

Hi mates, 

I have three columns, "Company", "COuntry" and "ValueX". 

I want to rank a company (by using a filter) base on "ValueX" within a selection of countries (another filter). I used the DAX as below with the purpose to keep the country filter and remove the company filter. However, it returns the rank of that company in ALL countries 😞 

 

Ranking = RANKX(ALLEXCEPT(Geography,Geography[Country]),[ValueX],,ASC,Skip)


Please help. 

Thank you so much in advance. 

4 REPLIES 4
Anonymous
Not applicable

@CNENFRNL Hi @CNENFRNL  can we have a call for about 10 mins then I can share my screen to you? I am so desperate now 😞 

The Allselected seems does not work either 😞

Anonymous
Not applicable

Hi @CNENFRNL , thank you so much for you reple. But I cant still get you quite clearly. Could you please advise me what should I do in this case? 

Hi, @Anonymous , I listed a direct reason that your measure returns the rank of that company in ALL countries; ALLEXCEPT(Geography,Geography[Country]) here is used as a table function, it returns Geography table without column [Country]; natually the filter on Geography[Country] is gone with the wind...

 

Without a close look at your data model, I could do nothing but to make a guess at my best,

Ranking = RANKX ( ALLSELECTED ( Geography[Country] ), [ValueX],, ASC, SKIP )

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

CNENFRNL
Community Champion
Community Champion

Hi, @Anonymous , ALLEXCEPT(T, C1, C2...) is tricky,

 

1. When used as a table function, ALLEXCEPT materializes all the unique combinations of the columns in the table specified in the first argument that are not listed in the following arguments;

 

2. When used as a modifier in CALCULATE or CALCULATETABLE, ALLEXCEPT removes the filters from the expanded table specified in the first argument, keeping only the filters in the columns specified in the following arguments.

 

You might to refer to the link for more details.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.