We are aware that in Tableau, we have the ability to utilize parameters for controlling the display of Top and Bottom N values in a single visual. However, you may wonder if the same functionality exists in Power BI. The answer is Yes! In this blog, I will show the necessary steps to achieve this.


1. Create a new table which will be used as a slicer then

2. Create a measure you want to show, in my case, it would be: Average Gini = AVERAGE(Sheet1[GINI])

3. Then, create the following measures

TopX = SELECTEDVALUE(Slicer[Value])  (we are taking the values which we created for slicer selection.)
TopRank = RANKX(ALL(Sheet1[Country]),CALCULATE([Average Gini]),,DESC) (Sort the countries in descending order)
BottomRank = RANKX(ALL(Sheet1[Country]),CALCULATE([Average Gini]),,ASC) (Sort the countries in ascending order)
Result =SWITCH(TRUE(),[TopRank]<=[TopX],1,[BottomRank]<=[TopX],-1,blank())
If the value of TopRank is equal to or less than the value of TopX, the result will be 1. Similarly, if the value of BottomRank is equal to or less than the value of TopX, the result will be -1. Otherwise, if neither of these conditions is met, the result will be left blank.

4. Then, drag the value we created before in the slicer table to slicer.

 5. Choose the bar type and drag country to y-axis, average gini to x-axis. And drag Result to filter, select not blank and apply filter.
Then you will have your chart.
The Data School
Author: The Data School