Forum Discussion

aaarmstee67's avatar
aaarmstee67
Icon for Helper I rankHelper I
8 years ago
Solved

Dynamic TopN Filter with multiple column

I am working on a project. I need to create a dynamic top n which should work when different slicers are used. I used RankX which gives me the results i need when i group on only one column, eg clien...
  • v-jiascu-msft's avatar
    v-jiascu-msft
    8 years ago

    Hi aaarmstee67,

     

    Seems your conditions here are different from your previous sample. But you can adjust it to satisfy your requirements. I have sent the demo base on your data through Private Message. 

    selectedTopN =
    VAR ranks =
        CALCULATE (
            RANKX ( ALL ( 'TESTPBI1'[contactname] ), CALCULATE ( SUM ( TESTPBI1[qty] ) ) ),
            ALLSELECTED ( TESTPBI1[companyname] ),
            ALLSELECTED ( TESTPBI1[country] ),
            ALLSELECTED ( TESTPBI1[Value] )
        )
    RETURN
        IF (
            ISBLANK ( 'TopN'[TopN Value] ),
            ranks,
            IF ( ranks <= 'TopN'[TopN Value], ranks, BLANK () )
        )
    

    Finally, you can select the top N value from the slicer and filter out the blanks to show top N only.

    topn2

     

     

    Best Regards,

    Dale