Forum Discussion
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
- rajendraongole1Super User
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
- thiamhuat2026Helper III
do you have the printscreens to show the step by step, please?
- thiamhuat2026Helper III
I follow your steps as below:
it does NOT work.
- rajendraongole1Super 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.
- thiamhuat2026Helper III
when Status=Close, that Top N does not work as below.
- rajendraongole1Super 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.
- FBergamaschiSuper User
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