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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

RANKX on filtered table

Apologies if this is obvious, i have not been able to find a solution for this.

 

I have this measure 

RANKX(ALLSELECTED(Table1),CALCULATE([measure), , DESC)
 
I would like to filter Table 1 so that only certain rows are ranked. I can achieve the same thing with a visual level filter but just looking to see if there is a simple way to do it in the measure.
 
Worth noting that [measure] is a sum of a seperate related table
1 ACCEPTED SOLUTION
CNENFRNL
Community Champion
Community Champion

 

=
IF(
    MAX( table1[PUBLISHED] ),
    RANKX(
        CALCULATETABLE( ALLSELECTED( table1[some column] ), table1[PUBLISHED] = TRUE ),
        [measure]
    )
)

 


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!

View solution in original post

4 REPLIES 4
CNENFRNL
Community Champion
Community Champion

 

=
IF(
    MAX( table1[PUBLISHED] ),
    RANKX(
        CALCULATETABLE( ALLSELECTED( table1[some column] ), table1[PUBLISHED] = TRUE ),
        [measure]
    )
)

 


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!

Anonymous
Not applicable

Brilliant, this works perfectly, thanks for your help.

selimovd
Super User
Super User

Hey @Anonymous ,

 

you can use the FILTER function to filter something.

And if you use a measure you don't need a CALCULATE without any parameters. Try the following approach:

RANKX(FILTER(ALLSELECTED(Table1), Table1[myColumn] = "MyValue"),[measure], , DESC)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hi Denis,

 

I have tried this but it is still giving ranks to rows that do not have that value:

 

RANKX(FILTER(ALLSELECTED(table1),table1[PUBLISHED]=true),[measure] , ,DESC)
GP93_1-1623934958416.png

 


 

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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