# Need help filtering a formula

**URL:** <https://community.weweb.io/t/need-help-filtering-a-formula/4097>\
**Category:** Ask us anything\
**Created:** [August 30, 2023, 6:43am UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097 "2023-08-30T06:43:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mark/32/4163_2.png) [@mark](https://community.weweb.io/u/mark)\
**Post date:** [August 30, 2023, 6:43am UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/1 "2023-08-30T06:43:40Z")

</div>

Hi, I have an array called ‘meditationInteractions’. One of the fields is a ‘meditation\_id’. I also have a variable called ‘currentAudio’ which holds an object that also has an id. What I’m trying to do is find the id of the ‘meditationInteraction’ object record, where its ‘meditation\_id’ matches the ‘currentaudio’ ID.

I have a split in Weweb that searches to see if a record exists. If it is false, it creates the record. That part is setup and working.

What I’m using this formula for is when the record is true, but I need the id so I know what record to update in Xano.

Normally I’d use Copilot for this but its rate limit is exceeded at the moment.

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 30, 2023, 7:03am UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/2 "2023-08-30T07:03:33Z")

</div>

Hey Mark, why don’t you use the GetKeyValue formula to extract out the meditation\_id from the object?

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mark/32/4163_2.png) [@mark](https://community.weweb.io/u/mark)\
**Post date:** [August 30, 2023, 7:14am UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/3 "2023-08-30T07:14:16Z")

</div>

Hi, I tried, but I’m not sure how to get it the formula to work correctly to get the result I want.

---

<div class="post-metadata">

**Author:** ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)\
**Post date:** [August 30, 2023, 7:15am UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/4 "2023-08-30T07:15:35Z")

</div>

Maybe you can show screenshots of what you’ve got so far and where the problem is…

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mark/32/4163_2.png) [@mark](https://community.weweb.io/u/mark)\
**Post date:** [August 30, 2023, 5:05pm UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/5 "2023-08-30T17:05:05Z")

</div>

Actually, I figured it out but I have a new one I’m struggling with thats a little similar.

It’s a simple favourite button that allows people to add their mark episodes as favourites.

In the picture below I believe I’ve figured out a way to display the element only if there is a meditationInteraction object that has the same meditation\_id as the current items meditation\_id.

What I actually want to do is only display it if the meditationInteractions ‘favourite’ record is false, as well as If there is no meditationinteraction record for this collection Item.

I already have the workflows that add and remove it from favorites setup and working, its just the displaying the icon that triggers those workflows thats giving me trouble.

 ![Screenshot 2023-08-30 at 11.04.33 AM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/ff24b75626ee544cbe7e5a4b91f78231506f41d3.png)

---

<div class="post-metadata">

**Author:** ![luka](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/luka/32/1571_2.png) [@luka](https://community.weweb.io/u/luka)\
**Post date:** [August 30, 2023, 9:03pm UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/6 "2023-08-30T21:03:03Z")

</div>

Edit:

You should probably use `lookup`

```auto
lookup(item.data.id ,meditationInteractions, "id")

```

this will return the object of the matching meditationInteractions. Keep in mind that if there isnt a meditationInteraction matching it will return undefined

After this if you want to see the value of favourite you can do

```auto
lookup(item.data.id ,meditationInteractions, "id").favourite

```

---

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mark/32/4163_2.png) [@mark](https://community.weweb.io/u/mark)\
**Post date:** [August 30, 2023, 9:17pm UTC](https://community.weweb.io/t/need-help-filtering-a-formula/4097/7 "2023-08-30T21:17:33Z")

</div>

Thanks! This works, and everytime you guy show me something like this it helps me understand the formulas better for future use cases, so I really appreciate your help.

I’m sure I can just use 3 different icons and display them conditionally. 1 if there are no interaction records at all, 1 if there is and the Favourite is false and another if its true.
