# Help with lookup formula

**URL:** <https://community.weweb.io/t/help-with-lookup-formula/5424>\
**Category:** Ask us anything\
**Tags:** design, supabase\
**Created:** [November 15, 2023, 10:29pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424 "2023-11-15T22:29:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 15, 2023, 10:29pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/1 "2023-11-15T22:29:59Z")

</div>

I have a field inside another table with the corresponding id in Supabase. I’m trying to use the lookup function in WeWeb to display the name of the item matching the id. This formula works on all others, but this one I can’t seem to get.

Am I overlooking something?

 ![CleanShot 2023-11-15 at 14.26.35@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/7959dcbde543435708e74d2e1153d334fe6b1448.png)

RLS is set to select for all, so just public on all tables. It’s a local version I’m using to test with.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [November 15, 2023, 11:01pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/2 "2023-11-15T23:01:20Z")

</div>

Hi @Lantzgould 👋

Can you show us the current value when you remove the `. name` at the end of the formula?

---

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 16, 2023, 12:44am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/3 "2023-11-16T00:44:27Z")

</div>

Hey @Joyce,

Comes to undefined when removing the `.name`.

 ![CleanShot 2023-11-15 at 16.43.02@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/978d23f7c998d4a98677c7598329205e60af49d5.png)

If I do a basic lookup on that table, I can grab the id no problem. Just when using it in this case I get the error and I’m a bit stumped.

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [November 16, 2023, 10:46pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/4 "2023-11-16T22:46:27Z")

</div>

Have you seen this video? [https://youtu.be/gu-YA606\_24](https://youtu.be/gu-YA606_24)

If you have, I would make sure to take it step by step to make sure your first `lookup` formula returns a value and then your `getKeyValue` formula that’s wrapped around it returns the result you expect and then the second `lookup` formula does to.

For example, I asked you to remove the `.name` because I suspected the formula didn’t return any data (and thus it didn’t make sense to look for the name inside an object since there was no object).

Does that make sense?

Sorry, it’s a bit hard to explain in writing but hopefully the video helps!

---

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 19, 2023, 3:26am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/5 "2023-11-19T03:26:46Z")

</div>

Hey @Joyce,

Thank you, yes I’ve seen the video. Interestingly, I can grab the id of the vehicle\_model, but cannot grab the name which is in the same table.

 ![CleanShot 2023-11-18 at 19.24.47@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/385f2867beb1c2a79662d38ef58718848aba6eeb.png)

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 19, 2023, 11:25am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/6 "2023-11-19T11:25:52Z")

</div>

I think you’re either not fetching it, or it’s nested. But might be wrong, I’d need to see the data structure. (Tables)

---

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 20, 2023, 4:03am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/7 "2023-11-20T04:03:57Z")

</div>

Thanks for taking a look, @Broberto.

Here’s what the setup looks like in Supabase:

Citations Table

 ![CleanShot 2023-11-19 at 20.00.35@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/df9acd05ccf8f20b5bf93f67118d8f4a47b8ab11.png)

Vehicle Model Table

 ![CleanShot 2023-11-19 at 20.01.47@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0b1407f2365a8f1354c24b67768df923928a318b.png)

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [November 20, 2023, 8:20am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/8 "2023-11-20T08:20:52Z")

</div>

Hmm can you show how you’re grabbing the name with the formula?

---

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 21, 2023, 12:31am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/9 "2023-11-21T00:31:05Z")

</div>

Sure, here’s a simple lookup using the first id from the list as an example:

 ![CleanShot 2023-11-20 at 16.29.25@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/b0ddaac9223609ffe105e688ecbca6e621c544b9.png)

And here’s what it looks like looking at the object without the name:

 ![CleanShot 2023-11-20 at 16.30.16@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/4/433095c780feb3679c95fa2e0bb587b9205eb30b.png)

---

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 24, 2023, 10:22pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/10 "2023-11-24T22:22:57Z")

</div>

Anyone else out there that might be able to assist? 🙂

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [November 27, 2023, 11:26am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/11 "2023-11-27T11:26:51Z")

</div>

This looks like a great start:

 ![CleanShot 2023-11-27 at 12.25.02@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/fa307937321964405236cf10a939e9074e8d554e.png)

From what I understand, you would like to get the value of `name`, correct?

If that’s the case, then adding `.name` or `["name"]` at the end of the formula above, after the parenthesis that closes the lookup, should work.

---

<div class="post-metadata">

**Author:** ![Lantzgould](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@Lantzgould](https://community.weweb.io/u/Lantzgould)\
**Post date:** [November 27, 2023, 7:57pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/12 "2023-11-27T19:57:32Z")

</div>

Thanks @Joyce.

Maybe I’ll submit a bug report, as these both still are returning errors on the simple lookup formula. The first of using `.name` returns

> Cannot read properties of undefined (reading ‘name’)

and using the `["name"]` returns

> Invalid or unexpected token

I suspect something with the schema from my specific table in Supabase is not in sync with WeWeb, as the rest of them work without any issues. 🤔

---

<div class="post-metadata">

**Author:** ![Corner](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Corner](https://community.weweb.io/u/Corner)\
**Post date:** [May 13, 2024, 3:33pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/13 "2024-05-13T15:33:38Z")

</div>

Hello, I’m kind of dealing with the same issue : “undefined” result when trying to use a lookup.  
Within a card from collection list (called “Remises”), I would like to display the name of a “Concession”, based on the id of a “Concession”, that is included in the “Remises” collection.  
But I get this undefined result …  
 ![Capture d'écran 2024-05-13 172610](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/6e90a3e7d05a77315e241e359160f16f31fd757b.png)  
Any ideas ?  
I’m using Supabase as a backend and here is a quick view of the schema :  
 ![Capture d'écran 2024-05-13 173306](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/35ba6cc672f4be8dfedbf2c9dd331bf5bfaa3ef7.png)  
Thanks !

EDIT : I managed to retrieve the info that I want thanks to the advanced method (directly when creating collection), but I would like to understand what am I doing wrong with lookup formula

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [May 13, 2024, 4:04pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/14 "2024-05-13T16:04:07Z")

</div>

Try to use Concession instead of Concession.data, what do you get ?

---

<div class="post-metadata">

**Author:** ![Corner](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Corner](https://community.weweb.io/u/Corner)\
**Post date:** [May 13, 2024, 4:46pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/15 "2024-05-13T16:46:15Z")

</div>

The same !  
 ![Capture d'écran 2024-05-13 183733](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d3af1f7a5ccdbd38f180c22b0c83efe9956179e6.png)

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [May 13, 2024, 6:09pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/16 "2024-05-13T18:09:26Z")

</div>

Use the log action to see inside the item and the collection variables. That will let you reason about. What you want to search and for what. If it’s not clear, share the results so others in the forum can point you in the right direction. “Inputs and outputs” is a key mental model at [state change](https://statechange.ai/) for cracking complex and non obvious problems.

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [May 14, 2024, 8:14am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/17 "2024-05-14T08:14:49Z")

</div>

As suggested by @raydeck you can try to display the current value of the purple and blue variable

You can remove the lookup end only keep item.data.concession\_id so it will display the value, then the same with Concession-\>data

It may be related to a type difference, maybe in Concession the id is a number, but in concession\_id it’s a text ?

---

<div class="post-metadata">

**Author:** ![Corner](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Corner](https://community.weweb.io/u/Corner)\
**Post date:** [May 14, 2024, 9:52am UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/18 "2024-05-14T09:52:55Z")

</div>

Thanks for your reply.

Maybe I’m missing something, but what should I seek for in the log as this is not an input field I’m dealing with, but rather a collection list. What I would like is to display in a collection list based on a “Remises” table (that is linked to “Concessions” table in Supabase) an information located within the “Concessions” table.

And what is surprising, is that when displaying only the id it’s working (once again, I would like to display the name of structures and not their id’s).

 ![Capture d'écran 2024-05-14 114536](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/2b951189bf21a05b58d7bb054766476f4a8671df.png)

It’s really the lookup that is not working, although there is a fk between “Remises” and “Concessions” table

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [May 14, 2024, 2:48pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/19 "2024-05-14T14:48:14Z")

</div>

Please show us now what contains the Concessions-\>data too, to check why lookup can’t find the item

It could happen if you have a filter or pagination on your collection and all the items are not loaded for exemple, lookup will search only on the available data

---

<div class="post-metadata">

**Author:** ![Corner](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@Corner](https://community.weweb.io/u/Corner)\
**Post date:** [May 14, 2024, 2:55pm UTC](https://community.weweb.io/t/help-with-lookup-formula/5424/20 "2024-05-14T14:55:29Z")

</div>

I checked if there was a blocking filter on the collection, but the only one is regarding the variable “search Concession” which is related to a search bar to look for “Concession” in the dedicated page (and enabled ignore when empty), so I don’t think that it has a impact on it.

See below the Concession data :  
 ![Capture d'écran 2024-05-14 165315](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/5/5abd968b981a0591f3e985ce4e8ae7e3cc476d90.png)

Thanks in advance

[Next page](https://community.weweb.io/t/help-with-lookup-formula/5424.md?page=2)
