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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chifflee
Regular Visitor

Rankx with a measure filter

Hello Guys,

I would like to ask your help:

Here the formula: TOP10_max =RANKX(ALL('product'[itemno]),[Overall scrap%],,DESC)
I used this measure to show the top10 item numbers (as a visualization filter - less than 11) by the highest scrap%. Which is worked properly.

 

But, now... I have to use a filter where the overall produced parts are > 10000 and I don't know how could I implement it. Because I have a measure for overall parts, but if I use as a visualization filter, it will filter only these 10 items where the produced parts are higher than 10000. So, is it possible to use a measure inside the rankx?
Produced parts are located in an another table where you can find the item number also, 'product'[itemno] is a main table without duplications.

Any idea?

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Chifflee ,

Do you want to get the rank which overall product parts greater than 10000 and Overall scrap% is top 10? If yes, you can create two measures as below:

Rank =
IF (
    [Overall products] >= 10000,
    RANKX ( ALLSELECTED ( 'product' ), CALCULATE ( [Overall scrap%] ) )
)
Top 10 =
VAR _nrank =
    IF (
        ISBLANK ( [Rank] ),
        BLANK (),
        RANKX ( ALLSELECTED ( 'product' ), [Rank],, ASC, DENSE ) - 1
    )
RETURN
    IF ( _nrank <= 10, _nrank, BLANK () )

Rank with measure filter.JPG

Otherwise, please provide some sample data in your model (exclude sensitive data) and your expected result with examples. Thank you.

Best Regards
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

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

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi @Chifflee ,

Do you want to get the rank which overall product parts greater than 10000 and Overall scrap% is top 10? If yes, you can create two measures as below:

Rank =
IF (
    [Overall products] >= 10000,
    RANKX ( ALLSELECTED ( 'product' ), CALCULATE ( [Overall scrap%] ) )
)
Top 10 =
VAR _nrank =
    IF (
        ISBLANK ( [Rank] ),
        BLANK (),
        RANKX ( ALLSELECTED ( 'product' ), [Rank],, ASC, DENSE ) - 1
    )
RETURN
    IF ( _nrank <= 10, _nrank, BLANK () )

Rank with measure filter.JPG

Otherwise, please provide some sample data in your model (exclude sensitive data) and your expected result with examples. Thank you.

Best Regards
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

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

Hi @v-yiruan-msft ,

Ah, I think your solution is works properly if I use visual level filters on the measures (not blank). 🙂 

Thanks a lot!

amitchandak
Super User
Super User

@Chifflee , on the way, use visual level filter for the part producted > 10000

 

TOP10_max =RANKX(ALLSELECTED('product'[itemno]),[Overall scrap%],,DESC)

 

or try like

TOP10_max =RANKX(ALLSELECTED('product'[itemno]),calculate([Overall scrap%], filter(Values('product'[itemno]),[part producted] >10000)),,DESC)

Hello @amitchandak ,

Your first suggestion: same result with visual level filter.

Second: Every item numbers has 1st rank, so top10 filter doesn't works. 😞 

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.