Search code examples
powerbidaxpowerquerygreatest-n-per-groupslicers

Dynamic TopN Selection problem while selecting another filter slicer?


In Power BI, I have created a dynamic TopN visual where we can see top 3 to top 10 teams in terms of total goals scored in FIFA World Cups. I am using a parameter called Top Rankings for TopN selection. However, the TopN selection does not work when I am selecting another slicer Year. When I am selecting the year slicer, the visual shows close to 10 teams although I have selected only 4 teams in the slicer parameter. I am providing the dax measure, table which is used to create the measure and the visual as well.

Dax -

# TopN Teams by Goal Scored = 
VAR ranking = RANKX(ALLSELECTED(All_WC_matches[Teams]), [Overall Scored],,DESC,Dense)
Return
IF(
    ranking <= 'Top Rankings'[Top Rankings Value],
    [Overall Scored]
)

Only TopN slicer selected

Only TopN slicer selected

Both TopN and Year slicers selected

Both TopN and Year slicer selected

Table used for the measure

Table used for the measure

This is the link to my power bi report https://app.powerbi.com/view?r=eyJrIjoiZWRkNjRkZmQtZGM5Ny00OTQyLTlmYjgtYzNhZGUxYTFkMTQ2IiwidCI6IjllMmY0M2FmLTExYzMtNGQ5NC1iYTVlLTc3Y2QwNzJlOWMwYiJ9

Link to my Power BI file https://drive.google.com/file/d/194jBF5M8KMLSAcfvzDjeotftdOahtnZG/view?usp=sharing

I am expecting that TopN selection will be affected by other slicers. However, the number of top teams selected will remain unchanged.


Solution

  • Your ranking is working as designed. i.e.

    Selecting top 3 and 1930 returns 7 results as you have 5 teams all scoring 7 goals. Look at the table below for an explanation.

    enter image description here