# Using Slice to limit the rows in a view (return Top n rows)

**URL:** <https://connect.superhuman.com/t/using-slice-to-limit-the-rows-in-a-view-return-top-n-rows/253>\
**Category:** Tips and Hacks\
**Created:** [March 2, 2018, 9:49pm UTC](https://connect.superhuman.com/t/using-slice-to-limit-the-rows-in-a-view-return-top-n-rows/253 "2018-03-02T21:49:55Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Tiago\_Melo](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/tiago_melo/32/6576_2.png) [@Tiago\_Melo](https://connect.superhuman.com/u/Tiago_Melo)\
**Post date:** [April 1, 2020, 12:00pm UTC](https://connect.superhuman.com/t/using-slice-to-limit-the-rows-in-a-view-return-top-n-rows/253/10 "2020-04-01T12:00:12Z")

</div>

Hello. It works for me but there’s something extra I wanted to do.  
I have a task table with some columns, but the ones that matter for this are **Urgency** (returns a float falue) and **Status** (Returns a pre-defined string such as ‘to-do, waiting, done, cancelled…’).  
Very well, I want to apply the slice in Urgency and sort it out by the highest value. Here’s the fórmula:

thisRow.In(thisTable.Sort(false(),thisTable.Urgency).Slice(1,3))

It works fine, but it brings all the tasks with all Statuses and I want to exclude some status from the result. However, if I try a different filter, it’ll apply over the previous one that is sliced already. For instance, let’s say that I have 5 tasks:

Task - Status - Urgency  
Task 5 (Next)(12)  
Task 7 (Cancelled)(13)  
Task 13 (To do)(15)  
Task 2 (Waiting)(20)  
Task 3 (To do) 17

The formula would return the tasks in this order: Task 2, Task 3 and Task 13, and that’s fine. But if I add another filter (let’s say that I want to filter out the status Waiting), then the two combined would return only Task 3 and Task 13. That’s kind of obvious, but what I want to do is filter statuses out and still receiving 3 values in a way that it would return the tasks 3, 13 and 7.

One way to do it (but that I cannot figure out how to apply a formula like this) would be having a formula that:

1. Sorts Urgency from highest number to low;
2. Filters out some statuses that I do not with to be shown;
3. Slice the result of the sort and the filter

Looks easy, but how to implement this in Coda?

Thanks in advance

---

_[View the full topic](https://connect.superhuman.com/t/using-slice-to-limit-the-rows-in-a-view-return-top-n-rows/253)._
