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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
icdns
Post Patron
Post Patron

Dynamic Ranking based on Filters selection

Hi, 

 

I would like to ask for your help in making my ranking dax dynamic based on filters selected. I have here my DAX, it is getting the correct ranking and values but it is only static and not changing based on my filter selection. 

 

I have a seperate table where in I can filter any dimension.. 

 

Here's my dax:

New Table 2 =
VAR _topNnumber = 5
VAR _totalsales =
    SUM ( Sales2[Sales] )
VAR _topfivesales =
    CALCULATE (
        SUM ( Sales2[Sales] ),
        TOPN (
            5,
            SUMMARIZE ( Sales2, Sales2[Category] ),
            CALCULATE ( SUM ( Sales2[Sales] ) ), DESC
        )
    )
VAR _topfivetable =
    ADDCOLUMNS (
        TOPN (
            _topNnumber,
            SUMMARIZE ( Sales2, Sales2[Category] ),
            CALCULATE ( SUM ( Sales2[Sales] ) ), DESC
        ),
        "@Sales", CALCULATE ( SUM ( Sales2[Sales] ) ),
        "@Ranking",
            RANKX (
                SUMMARIZE ( Sales2, Sales2[Category] ),
                CALCULATE ( SUM ( Sales2[Sales] ) ),
                ,
                DESC
            ),
        "@contribution", FORMAT ( CALCULATE ( SUM ( Sales2[Sales] ) ) / SUM ( Sales2[Sales] ), "#0.00%" )
    )
VAR _otherstable =
    {
        ( "Others", _totalsales - _topfivesales, _topNnumber + 1, FORMAT ( ( _totalsales - _topfivesales ) / _totalsales, "#0.00%" ) )
    }
RETURN
    UNION ( _topfivetable, _otherstable )

 

Thank you in advance!

2 REPLIES 2
Anonymous
Not applicable

Hi @icdns ,

In order to better understand your demands and give the right solution, could you please provide some more specific information? such as your desensitized example data and a screenshot of your desired results?

Thanks for your efforts & time in advance.

 

Best regards,
Community Support Team_ Binbin Yu

amitchandak
Super User
Super User

@icdns , Can please explain what are you trying to achieve here?

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

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.