# Top() and limit() function won't work

**URL:** https://community.influxdata.com/t/top-and-limit-function-wont-work/23481
**Category:** Fluxlang
**Tags:** query, flux
**Created:** [January 21, 2022, 10:57pm UTC](https://community.influxdata.com/t/top-and-limit-function-wont-work/23481 "2022-01-21T22:57:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![user1912](https://avatars.discourse-cdn.com/v4/letter/u/41988e/32.png) [@user1912](https://community.influxdata.com/u/user1912)
#### Post date: [January 21, 2022, 10:57pm UTC](https://community.influxdata.com/t/top-and-limit-function-wont-work/23481/1 "2022-01-21T22:57:08Z")

</div>

Hello guys. I’ve been struggling with something.  
I am using the table format in grafana and it won’t limit the results to just showing the “top 10”.  
I’ve tried both the limit and top function, but basically nothing happens. I’ve been through the documentation and am hoping someone on this community could help me out.

QUERY:

bucketdata = from(bucket: “BUCKETNAME”)  
|\> range(start: v.timeRangeStart, stop: v.timeRangeStop)  
|\> filter(fn: (r) =\> r["\_measurement"] == “raw\_data”)  
|\> filter(fn: (r) =\> r["\_field"] ==“last\_cpu\_time”)  
|\> sort(columns: [“last\_cpu\_time”], desc: true)  
|\> limit(n:10)  
|\> yield()

This won’t even work with one field measurement, in the ideal scenario I’d like to use more measurements than just last\_cpu\_time and grouping them. But can’t seem to get it to work with just one already, let alone more fields.

---

<div class="post-metadata">

### Author: ![skartikey](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/skartikey/32/19710_2.png) [@skartikey](https://community.influxdata.com/u/skartikey)
#### Post date: [February 9, 2022, 10:24am UTC](https://community.influxdata.com/t/top-and-limit-function-wont-work/23481/2 "2022-02-09T10:24:53Z")

</div>

@user1912 Looks like a simple query that should work. Could you please check if filters are returning records before piping to sort, limit, etc?
