Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
2 years ago
Solved

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
Why would all the top 10 get the same results? Thanks a lot.
  • 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 )
        )
    )

4 Replies

  • 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 )
        )
    )