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

How to create dynamic top and bottom 5 rank with slicer as button in one measure power bi

Created Top & bottom rank while other value are blank which are not in top or bottom rank
 
topbottom =
                VAR Top5 = CALCULATE(RANKX(ALL(matches[winner]),[win_by_runs_measure],,DESC,Skip), ALL(matches), VALUES(matches[winner]))

                VAR Bottom5 = CALCULATE(RANKX(ALL(matches[winner]),[win_by_runs_measure],,ASC,Skip), ALL(matches), VALUES(matches[winner]))
 
 

                    RETURN
                     IF(Top5<=5,"Top",IF(Bottom5<=5,"Bottom",BLANK()))
1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have create a simple sample:

vjianbolimsft_0-1659927685895.png

Please try:

topbottom =
VAR _a =
    SUMMARIZE ( ALLSELECTED ( matches ), 'matches'[winner] )
VAR TOP5 =
    MAXX (
        FILTER (
            ADDCOLUMNS ( _a, "Rank", RANKX ( _a, [win_by_runs_measure],, DESC, SKIP ) ),
            [winner] = MAX ( 'matches'[winner] )
        ),
        [Rank]
    )
VAR Bottom5 =
    MAXX (
        FILTER (
            ADDCOLUMNS ( _a, "Rank", RANKX ( _a, [win_by_runs_measure],, ASC, SKIP ) ),
            [winner] = MAX ( 'matches'[winner] )
        ),
        [Rank]
    )
RETURN
    IF ( Top5 <= 5, "Top", IF ( Bottom5 <= 5, "Bottom", BLANK () ) )

Final output:

vjianbolimsft_1-1659927858249.png

vjianbolimsft_3-1659927902756.png

 

Best Regards,

Jianbo Li

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

5 REPLIES 5
v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or if you are still confused about it, please provide me with more details about your table and your problem or share me with your pbix file after removing sensitive data.

 

Best Regards,

Jianbo Li

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

v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Yes, there is no DAX for slicer, the measure will dynamicly rank for the visual after the slicer filtering the data. In this condition, you do not need DAX for slicer.

 

Best Regards,

Jianbo Li

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

v-jianboli-msft
Community Support
Community Support

Hi @Anonymous ,

 

Based on your description, I have create a simple sample:

vjianbolimsft_0-1659927685895.png

Please try:

topbottom =
VAR _a =
    SUMMARIZE ( ALLSELECTED ( matches ), 'matches'[winner] )
VAR TOP5 =
    MAXX (
        FILTER (
            ADDCOLUMNS ( _a, "Rank", RANKX ( _a, [win_by_runs_measure],, DESC, SKIP ) ),
            [winner] = MAX ( 'matches'[winner] )
        ),
        [Rank]
    )
VAR Bottom5 =
    MAXX (
        FILTER (
            ADDCOLUMNS ( _a, "Rank", RANKX ( _a, [win_by_runs_measure],, ASC, SKIP ) ),
            [winner] = MAX ( 'matches'[winner] )
        ),
        [Rank]
    )
RETURN
    IF ( Top5 <= 5, "Top", IF ( Bottom5 <= 5, "Bottom", BLANK () ) )

Final output:

vjianbolimsft_1-1659927858249.png

vjianbolimsft_3-1659927902756.png

 

Best Regards,

Jianbo Li

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

 

Anonymous
Not applicable

THANKS 

Anonymous
Not applicable

There is no dax for slicer ?

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.