# Formula - Getting the first item in 'Rank' order

**URL:** <https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321>\
**Category:** Get Help\
**Created:** [June 22, 2024, 7:22pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321 "2024-06-22T19:22:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![grex22](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/grex22/32/10249_2.png) [@grex22](https://community.fibery.io/u/grex22)\
**Post date:** [June 22, 2024, 7:22pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321/1 "2024-06-22T19:22:33Z")

</div>

So, I have an entity “Task”, and it has sub Tasks. Sub Tasks can be marked completed or not, of course.

The Sub Tasks are drag-n-dropped into the order that makes sense for completion, and some may be completed along the way… so for example, a Task that is in progress could look like:

Task: Get Groceries  
SubTask: Drive to the store [DONE]  
SubTask: Put groceries in cart [not done]  
SubTask: Pay for groceries [not done]  
…

I’m trying to create a formula on the parent Task that returns the “first” non-completed task. This is what I have now:

```auto
[Sub-Tasks]
  .Filter(State.Name != "Done")
  .Sort([Creation Date])
  .First()

```

The problem is the .Sort([Creation Date]), because that’s not really what I want (but of course you HAVE to Sort before a First). Sorting on Creation Date works if the tasks were always entered chronologically in the right order, but as soon as I remember a step I forgot, add that new step, and drag it into its correct spot, Creation Date is now suddenly not the correct Sort order.

I know there’s not a way to Filter / Sort based on the Entity’s position in a view, but what about a collection. Since I’m accessing the specific Parent Task, is there no way to grab the first Sub Task Entity in the order shown in that Parent’s Entity view?

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [June 22, 2024, 9:54pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321/2 "2024-06-22T21:54:31Z")

</div>

If you leave the sort parameter empty, it will sort on rank, which is the positional order.  
e.g. `Sort().First()`

---

<div class="post-metadata">

**Author:** ![grex22](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/grex22/32/10249_2.png) [@grex22](https://community.fibery.io/u/grex22)\
**Post date:** [June 24, 2024, 1:44pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321/3 "2024-06-24T13:44:32Z")

</div>

Thanks @Chr1sG ! I’d considered this (and even tried it), but what I was not realizing was that if my Entity view of the SubTasks had a sort applied, Sort().First() ignores that. Which makes sense, now that I think about it, but it took me a bit of time to realize what was happening.

Thanks for the fast responses as always, Chris!

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [June 24, 2024, 1:52pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321/4 "2024-06-24T13:52:09Z")

</div>

~~It shouldn’t work as you have described (assuming I have understood).~~  
If your formula uses `Sort().First()` then the application of a sort on the relation field view should have no impact on the formula result.  
👍

---

<div class="post-metadata">

**Author:** ![grex22](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/grex22/32/10249_2.png) [@grex22](https://community.fibery.io/u/grex22)\
**Post date:** [June 24, 2024, 2:18pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321/5 "2024-06-24T14:18:12Z")

</div>

That’s correct, that was the behavior I was seeing as well (I just did a poor job of explaining it).

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [June 24, 2024, 2:37pm UTC](https://community.fibery.io/t/formula-getting-the-first-item-in-rank-order/6321/6 "2024-06-24T14:37:20Z")

</div>

OK, my bad. I misunderstood what you meant.
