Instead of filter, you can go with the Parameter for getting the result. I have done the top and bottom multiple times in many of the tableau visualizations and its so easy.
Below are the steps to achieve your requirement.
Create a parameter that will allow you to select top and bottom
Create another parameter that will allow you to select the desired numbers like 5, 10, 15 etc.

Here i have created a parameter that will have values from 10 to 50 in a step size of 10.
- Create a calculated field that will subset data based on the parameters chosen

In the above screenshot, I am using the top site parameter and creating a conditional statement that will show the states based on the value chosen in the site parameter and the value for that state.
- Put the calculated field in the filter and select show and click ok in the filter box.
Now the view will show the top count based on the value selected in the parameter.
Please note the calculation is for top N and for bottom N you need to change the calculation.
Hope this will help you. I can provide you a workbook if you need.