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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

TopN Problems Same result

Hello, I am making a dashboard with open data on Bullying in Peru and I want to make a top 10 of the subtypes of violence, it should be noted that they are string data, and use this dax:

Top10 = CALCULATE([Subtypes],TOPN(10,ALL('DM Facts'[SUBTIPO_VIOLENCIA]),[Subtypes],DESC),VALUES('Type of SubViolence'[SUBTIPO_VIOLENCIA]))
[Subtypes] is COUNTROWS('DM Facts')
However, it gives me all the same results top.png
Why would all the top 10 get the same results? Thanks a lot.
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

The TOPN is changing the fitler context to override the line, try it with a KEEPFILTERS.

Top10 =
CALCULATE (
    [Subtypes],
    KEEPFILTERS (
        TOPN ( 10, ALL ( 'DM Facts'[SUBTIPO_VIOLENCIA] ), [Subtypes], DESC )
    )
)

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I didn't know I had to share the download link.

jdbuchanan71
Super User
Super User

The TOPN is changing the fitler context to override the line, try it with a KEEPFILTERS.

Top10 =
CALCULATE (
    [Subtypes],
    KEEPFILTERS (
        TOPN ( 10, ALL ( 'DM Facts'[SUBTIPO_VIOLENCIA] ), [Subtypes], DESC )
    )
)

Indeed this is the solution, thank you very much.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.