# Filter N entity in automation formula

**URL:** <https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863>\
**Category:** Ideas & Features\
**Tags:** automations\
**Created:** [July 28, 2023, 2:20pm UTC](https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863 "2023-07-28T14:20:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TonyLH](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tonylh/32/7196_2.png) [@TonyLH](https://community.fibery.io/u/TonyLH)\
**Post date:** [July 28, 2023, 2:20pm UTC](https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863/1 "2023-07-28T14:20:00Z")

</div>

Hi!  
I have an automation formula that adds the first empty (free) entity.  
Kings.Filter(IsEmpty(Setups) = true)  
.Sort([Public Id])  
.First()

How can I get 5 entities at once?

---

<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:** [July 28, 2023, 3:57pm UTC](https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863/2 "2023-07-28T15:57:57Z")

</div>

I am not aware of an easy way of doing it, but you could achieve it by adding 1 entity at a time, five times.

However, for each action (except the first) you would need to include in the filter condition that it is not already linked, which may or may not be easy (possible?) depending on the relation type (one-to-many 👍 many-to-many 👎 )

---

<div class="post-metadata">

**Author:** ![TonyLH](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tonylh/32/7196_2.png) [@TonyLH](https://community.fibery.io/u/TonyLH)\
**Post date:** [July 31, 2023, 10:39am UTC](https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863/3 "2023-07-31T10:39:00Z")

</div>

Thanks for the idea! but it probably won’t work that way because the trigger is set to add a new line. Some kind of automatic filling of fields. You can’t call it 5 times in a row.

I guess I’ll have to try to find a solution through JS

---

<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:** [July 31, 2023, 11:20am UTC](https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863/4 "2023-07-31T11:20:17Z")

</div>

Maybe I misunderstood, but I meant that you could use 5 actions in one automation, with the same formula each time, that checks for which entity should be linked.

Here’s an analogous example where I am linking a Project to the top 3 Deliverables (ordered by Creation date) which are not Done and are not already linked to a Project:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/d/d72c569e128305bff47fb0374964cd7cf54ceb72.png)  
This is the formula:

```auto
Deliverables.Filter(Done = false and IsEmpty(Project))
  .Sort([Creation Date])
  .First())

```

And here’s what happens when it runs:  
 ![firefox_UHTUu2QMOg](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/1/16f446207705dc5bcfd0c487b5ff58de3f0f1d26.gif)

Is this close to what you need?

---

<div class="post-metadata">

**Author:** ![TonyLH](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/tonylh/32/7196_2.png) [@TonyLH](https://community.fibery.io/u/TonyLH)\
**Post date:** [July 31, 2023, 12:39pm UTC](https://community.fibery.io/t/filter-n-entity-in-automation-formula/4863/5 "2023-07-31T12:39:05Z")

</div>

Yes, it did! Thank you!  
I didn’t realize it at first and did it wrong with UPDATE.  
I should have done it with LINK. ))))

solved))))
