To link Slider with straight table

Hi Geniuses,

I have a straight table and a slider, I wanna link these two so that if the user selects 5 on the slider the sum of top 5 records will get displayed in straight table same goes for top 10 and so on....