Forum Discussion

thiamhuat2026's avatar
thiamhuat2026
Helper III
4 months ago
Solved

Top N not working when filtering

this works when Status = Closed, but when I choose other filters, it does not work. Why?

 

 

 

  • Hi thiamhuat2026 - Instead of relying on the built-in Top N filter,

    Use ranking measure:

    Eg:

    Rank =

    RANKX(

        ALLSELECTED('Table'[Category]),

        CALCULATE(COUNT('Table'[CaseID])),

        ,

        DESC,

        DENSE

    )

    Then create filter measure 

    TopN Filter =

    IF([Rank] <= 5, 1, 0)

     

    Apply this to the visual

    Add TopN Filter to Filters on this visual

    Set it to is 1

     

    This way it works

    Pls check 

     

7 Replies

  • Hi thiamhuat2026 - Instead of relying on the built-in Top N filter,

    Use ranking measure:

    Eg:

    Rank =

    RANKX(

        ALLSELECTED('Table'[Category]),

        CALCULATE(COUNT('Table'[CaseID])),

        ,

        DESC,

        DENSE

    )

    Then create filter measure 

    TopN Filter =

    IF([Rank] <= 5, 1, 0)

     

    Apply this to the visual

    Add TopN Filter to Filters on this visual

    Set it to is 1

     

    This way it works

    Pls check 

     

    • thiamhuat2026's avatar
      thiamhuat2026
      Helper III

      do you have the printscreens to show the step by step, please?

      • rajendraongole1's avatar
        rajendraongole1
        Super User

        DO NOT use “Top N” filter anymore, use measure 

        Rank =

        RANKX(

            ALLSELECTED('tc_merged_gold'[Block_Address]),

            CALCULATE(COUNT('tc_merged_gold'[CaseID])),

            ,

            DESC,

            DENSE

        )

        In the visual filter pane

        Drag TopN Filter logic shared above for this

        Change filter type to: Basic filtering OR Advanced filtering and set 

        TopN Filter = 1

        Thats it.

        Hope this helps.

         

    • rajendraongole1's avatar
      rajendraongole1
      Super User

      Hi thiamhuat2026 - as mentioned above logic,

      Ensures Top N is calculated within the active filter context.Produces consistent, expected results

      Pls check and confirm.

  • Hi thiamhuat2026 

    from my point of view, answering a request like this is impossible without more hints on:

    - data model

    - grouped columns in the visual showing issues

    - some data to replicate the problem

     

    so, please include, in a usable format, not an image, a small set of rows for each of the tables involved in your request and show the data model in a picture, so that we can import the tables in Power BI and reproduce the data model. The subset of rows you provide, even if just a subset of the original tables, must cover your issue or question completely. Alternatively, you can share your .pbix via some cloud service and paste the link here. Do not include sensitive information and do not include anything that is unrelated to the issue or question. Please show the expected outcome based on the sample data you provided and make sure, in case you show a Power BI visual, to clarify the columns used in the grouping sections of the visual.

     

    IN this way I will be able to help, DAX is my specialty

     

    Need help uploading data? click here

     

    Want faster answers? click here