# How to check entity is NOT empty (in formula)?

**URL:** <https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427>\
**Category:** Get Help\
**Created:** [January 21, 2022, 8:29pm UTC](https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427 "2022-01-21T20:29:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![masp](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@masp](https://community.fibery.io/u/masp)\
**Post date:** [January 21, 2022, 8:29pm UTC](https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427/1 "2022-01-21T20:29:59Z")

</div>

Can’t figure out how to check if an entity is NOT empty. This formula would work for checking if it IS empty:

`Epics.Filter([Tasks In Progress].IsEmpty)`

but I can’t figure out how to negate it (there seems to be no `IsNotEmpty()` and no `Not` operator. I’m sure it’ll be obvious in retrospect!

Update: actually that formula seems incorrect; but so is:

`Epics.Filter(IsEmpty([Tasks In Progress]))`

I realised that if I can get `IsEmpty()` to work then I can probably just write `IsEmpty(.) != true` but I can’t get the `IsEmpty()` syntax correct yet…

OK so [Tasks In Progress] is defined like this (formula):

`Tasks.Filter(State.Name = "In Progress")`

which works (results in a entity which is a collection of Tasks). I don’t seem to be able to apply `IsEmpty()` or `Count()` to `[Tasks In Progress]` in a subsequent formula. So I guess I should maybe generalize my question to: how can I create a formula which incorporates a count into its filter function?

Thanks!

---

<div class="post-metadata">

**Author:** ![Haslien](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/haslien/32/493_2.png) [@Haslien](https://community.fibery.io/u/Haslien)\
**Post date:** [January 21, 2022, 11:36pm UTC](https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427/2 "2022-01-21T23:36:18Z")

</div>

Hey, you should be able to use the `If(condition, ifTrue, ifFalse)` to invert it.  
Simply return `True` on `ifFalse` and `False` on `ifTrue`.

A simple example of inverting True/False:

```auto
If(IsEmpty(Collection), False, True)

```

> [@masp](#):
>
> So I guess I should maybe generalize my question to: how can I create a formula which incorporates a count into its filter function?

Not entirely sure what you’re asking for, but it seems like inverting is no longer part of it judging from your final question too. I’ll try to answer it regardless.

There are some restrictions on the level of depth you can make the formulas go. Imagine we have this setup, and we want a # of Epics that have features populated, as a field in `Product`:

```auto
Product
  ╘ Epic
    ╘ Feature

```

On `Product`:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/e/e58e99e3de39cdfe179323129ad2406c9acc00aa.png)

As you can see, this doesn’t work. It tells us to use two Formulas. To translate that into what you would have to do: we just need to pass some pre-calculated values up instead of doing it all at the top.

In `Epic` we have this simple formula:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/f/f78ab5db420836113fe58af199980a52b77d5696.png)

And then we can modify the formula for `Product` to be this:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/fibery/original/2X/a/a939fe6bbca6420037111c1f1a0922940f265203.png)

It’s the same thing, but now we get a working formula 🙂

[https://i.thevirt.us/01/V6x0F.mp4](https://i.thevirt.us/01/V6x0F.mp4)

---

<div class="post-metadata">

**Author:** ![masp](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@masp](https://community.fibery.io/u/masp)\
**Post date:** [January 22, 2022, 2:04am UTC](https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427/3 "2022-01-22T02:04:57Z")

</div>

Got it: works for me.

BTW I’m trying to something related which I can’t figure out: in that same example (Product-\>Epic-\>Feature), I’d like create a list of all the Features (via all Epics) at the Product level: ie. each Epic has a list of features (say: Epic.Features), and I want to define Product.Features = Union(Epic.Features for all Epics) (as it were). I can’t see any way to do that: is there a Union function (or some pattern that would do this for me)?

Concrete example: say Epic.Features = (a, b, c) and Epic2.Features = (d, e, f) then I want to automatically derive Product.Features = (a,b,c,d,e,f).

---

<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:** [January 22, 2022, 8:00am UTC](https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427/4 "2022-01-22T08:00:15Z")

</div>

You can just create a lookup (not a formula) in Products that gets all Features from all Epics.

---

<div class="post-metadata">

**Author:** ![masp](https://avatars.discourse-cdn.com/v4/letter/m/46a35a/32.png) [@masp](https://community.fibery.io/u/masp)\
**Post date:** [January 22, 2022, 4:59pm UTC](https://community.fibery.io/t/how-to-check-entity-is-not-empty-in-formula/2427/5 "2022-01-22T16:59:32Z")

</div>

Wow, that’s awesome!!! Thanks!
