You can create a Parameter for allowing the user to select the number of rows to show. This can be an open number field or a select list with pre-defined values (25,100, etc).
Now comes the tricky part....
I've had success with this before creating a Table Calculation - Running Total on a field that will only return 1 for each row. This could be a distinct count of customerid perhaps. Will be 1 for each row and then the running total will increment it by one. Make sure you tell it to compute using Table Down.
If you also do a sort on customerId by salesVolume desc, you will get a numbered list next to your rows. This in itself can be handy for showing a ranking report that can be dynamically generated in Tableau.
Now if you go to Edit Table Calculation and Customize, you get the option to create a Calculated Field using this rank number. It may start with something like: RUNNING_SUM(Countd([CustomerId]))
Update the Formula to be: If RUNNING_SUM(Countd([CustomerId])) <= [UserDisplayRows] then 'Show' else 'Hide' end. Then Name this field RowFilter and OK.
Now drag your RowFilter calculated field to the filters shelf and filter to 'Show'. --Again make sure the filter is set to compute using -> Table Down.
Thats IT! now you can update your parameter value and the number of rows showing will update automatically.
If you have a total on your table, this will be affected by your filter as it will only show total of rows being shown. To get around this, don't place the RowFilter on the filter shelf, but put it on your row/column shelf. You should see your top rows displaying 'Show' in that column and the rest showing 'Hide'. Right click on a Hide row and chose the Hide option. This will take away the rows above your selection, but leave the grand total in tact.
Similar to Nathan's answer, instead of using running_sum(countd([fieldname])) the index function can be used as well. The index function returns the the current row in the partition. So using a similar calculation where this function is used with the parameter, and placing it on the filter shelf will return the same outcome. As Nathan stated, make sure that the calculation is computed using Table Down.
If Index()<= [UserDisplayRows] then 'Show' else 'Hide' end
Thanks Nathan. I will give this a try and let you know how it works out.
Thanks Tracy. I'll give it a try.