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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Maikeru
Helper II
Helper II

RANKX with condition

Hi,

 

I am trying to create a RANKX measure on customers meeting a certain revenue conditions.

 

 

Rank top 100 = 
VAR Customer_list = 
FILTER(
ALLSELECTED(Revenue[Customer]), 
[Revenue total] < 50000000 && [Revenue total] > 30000000
)

VAR RANK_DESC = 
RANKX(
FILTER(ALLSELECTED(Revenue[Customer]), Revenue[Customer] IN Customer_list),
[Revenue total],
,
DESC)

RETURN
IF (ISINSCOPE(Revenue[Customer]),
IF(RANK_DESC <= 100, RANK_DESC, BLANK()),
BLANK()
)

 

 

 

However the measure would still evaluate customers which do not meet the criteria.

Image 12.png

The dataset is a standard sales transactional table: date, customer, revenue.

 

Any ideas would be appreciated.

 

Best regards.

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Maikeru , Prefer filter in measure and then use it RankX. Means have all filter in the measure and then use that measure in Rank

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Maikeru , Prefer filter in measure and then use it RankX. Means have all filter in the measure and then use that measure in Rank

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak., for the articles. 
The trick to use CONCATENEX is very useful. Now I understand better the inner mechanics of RANKX.

I finally went for the RANKX applied on a filtered measure solution.

Pragati11
Super User
Super User

Hi @Maikeru ,

 

In your following DAX, can you use your "Customer_list" directly, rather using IN operator.

 Basically, rank your customer List and check. This should resolve the isssue.

VAR RANK_DESC = 
RANKX(
FILTER(ALLSELECTED(Revenue[Customer]), Revenue[Customer] IN Customer_list),
[Revenue total],
,
DESC)

  So, in above RANKX directly use CUSTOMER LIST.

 

If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Thanks @Pragati11.

 

I tried your idea, but the result was exactly the same.

    RANKX(
        FILTER(
            ALLSELECTED(Revenue[Customer]), 
            [Revenue total] < 50000000 && [Revenue total] > 30000000
            ),
        [Revenue total],
        ,
        DESC)

 

Greg_Deckler
Community Champion
Community Champion

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.