How to return top X using a paramter

Start with what @knash did here:

and replace the