Forum Discussion

Ania26's avatar
Ania26
Helper IV
9 months ago
Solved

TOP N

I would like to have stucked column chart where I show top 3 countries plus Others per year.  Those top 3 countries must be selected among all years and be the same every year so in this case it will be Comoros,Turkmenistan,Liberia. Those 3 countries I would like to show on he chart per year and remaining countires as Others. Then I would like to have it sorted , Others at the top. 
Year Region Country Value
2013 Americas Caribbean Other 1
2013 Americas Paraguay 2
2014 Americas Congo 3
2013 Americas DEM. REP. OF CONGO 2
2013 Americas Equatorial Guinea 3
2014 Americas Eritrea 4
2013 Americas Kyrgyzstan 4
2013 Americas Lesotho 3
2013 Americas Liberia 22
2014 Americas Malawi 1
2013 Americas Maldives 2
2013 Europe Bosnia And Herzegovina 3
2013 Europe Botswana 2
2013 Europe Burundi 3
2014 Europe Cape Verde 4
2013 Europe Car Central Af. Rep 4
2013 Europe Chad 3
2014 Europe Comoros 22
2013 SSEA-CIS-MEA Mayotte 1
2013 SSEA-CIS-MEA Namibia 2
2013 SSEA-CIS-MEA Other South Pacific 3
2013 SSEA-CIS-MEA Reunion 2
2013 SSEA-CIS-MEA Seychelles 3
2013 SSEA-CIS-MEA Sri Lanka 4
2014 SSEA-CIS-MEA Swaziland 4
2014 SSEA-CIS-MEA Turkish Cyprus 3
2013 SSEA-CIS-MEA Turkmenistan 22
2014 SSEA-CIS-MEA Zimbabwe 1
2013 SSEA-CIS-MEA Tajikistan 2
2013 SSEA-CIS-MEA Bahrain 3
2013 SSEA-CIS-MEA Uganda 4

  • Ania26 . First create a measure 

    All Time = calculate([You measure], all('Date')) // Assuming you are using Date table   

     

    or

     

    All Time = calculate([You measure], all('Table'[Date]))
    Then you can use TOPN or Window

     

    example 

    M1= calculate([All Time], keepfilters(topn(3, allselected(Geo[Country]), [All Time], desc) )

    Dynamic TOPN using TOPN/Window and Numeric parameter: https://youtu.be/vm2mdEioQPQ

     

     

1 Reply

  • Ania26 . First create a measure 

    All Time = calculate([You measure], all('Date')) // Assuming you are using Date table   

     

    or

     

    All Time = calculate([You measure], all('Table'[Date]))
    Then you can use TOPN or Window

     

    example 

    M1= calculate([All Time], keepfilters(topn(3, allselected(Geo[Country]), [All Time], desc) )

    Dynamic TOPN using TOPN/Window and Numeric parameter: https://youtu.be/vm2mdEioQPQ