# Display the desired field

**URL:** <https://community.weweb.io/t/display-the-desired-field/3406>\
**Category:** How do I?\
**Created:** [July 6, 2023, 4:50pm UTC](https://community.weweb.io/t/display-the-desired-field/3406 "2023-07-06T16:50:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 6, 2023, 4:50pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/1 "2023-07-06T16:50:14Z")

</div>

Hi.  
Why is the id displayed when data is plugged in, when a completely different field is selected?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/b46a0adc0011e70a52b80590b1299c18f846456e.png)

---

<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:** [July 6, 2023, 9:20pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/2 "2023-07-06T21:20:57Z")

</div>

Hi @icos 👋

It looks like your `properties` table is referencing the `type` table in Supabase. In WeWeb, your Properties collection is not fetching the type name but only the type id.

But you have the type names in the Type collection, so when binding info on an item from the Properties collection, you could use the `lookup` formula to look for the id of the `type` in the Type collection.

In the example below, I had a list of vehicles from a vehicles table with a reference to a `location_id` (2) from another table and used the lookup formula to get the name of that location from my locations collection:

 ![CleanShot 2023-07-06 at 23.16.13@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/973a51f4a186a56fe4b276446dcf4da23bfdfa63.jpeg)

Does that help?

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 7, 2023, 10:46am UTC](https://community.weweb.io/t/display-the-desired-field/3406/3 "2023-07-07T10:46:04Z")

</div>

Thanks @Joyce everything worked, but why is it so complicated?  
In Supabase I have a column Region and id is displayed there, but in WeWeb it is transferred all right. With others I have to dance with tambourine).

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/88871564c577a239cf0bfec757528cfff1da1d91.png) ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/6203981e5bdcd55688ff5821ee6a1021af78723b.png)

---

<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:** [July 7, 2023, 3:39pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/4 "2023-07-07T15:39:12Z")

</div>

Hi @icos ,

I think you are confusing two things in your screenshot:

1. the region name is coming from your `Region` collection,
2. the `region` value you highlighted in red is in an item in another collection

So it’s not any different to the issue we discussed above with the Properties and Type collections.

When working with related fields in a relational database, you have several approaches (I’ll explain with WeWeb and Supabase as an example but it’s not specific to these tools):

**Option 1** - create a view in Supabase that has all the information you need, i.e. the values themselves, not the references. Then you can create a collection in WeWeb with the data from that view. The downside is you can’t use the realtime functionality of the table anymore [as discussed in this topic](https://community.weweb.io/t/filtering-for-referenced-fields-in-tables/3397/5).

**Option 2** – [use the advanced mode when creating a collection](https://docs.weweb.io/plugins/data-sources/supabase-data.html#get-data-from-supabase) to get the names of reference fields in other tables. This works well but, depending on your use case, may be limiting. For example if you need to filter through the related field, as discussed in the same topic mentioned above.

**Option 3** - create a collection for each table in WeWeb and use the `lookup` formula to display the value from a reference field.

Option 3 is my preferred solution for your use case because:

- you already have those collections in your project
- you don’t have to load the same data twice

All three approaches are valid in terms of web development but option 3 will most likely scale better.

Does that clarify things a little bit?

No worries if not, I’ll try to record a video tutorial explaining a bit better how things work and why.

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 7, 2023, 9:12pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/5 "2023-07-07T21:12:13Z")

</div>

Yes, I realized my mistake.  
I need to find something out and check it out.  
Thank you!

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 14, 2023, 9:37am UTC](https://community.weweb.io/t/display-the-desired-field/3406/6 "2023-07-14T09:37:32Z")

</div>

Greetings @Joyce  
Something is not working with your formula).  
I use it for other columns, but in each case different problems  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/f/fa7233ccb06372d4b84a60bb8e25adbdcd31013d.png)

![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/4/400477d6cfacf76e67ebc433721c7560735b59e9.png)  
What could be the error?

---

<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:** [July 14, 2023, 10:03am UTC](https://community.weweb.io/t/display-the-desired-field/3406/7 "2023-07-14T10:03:48Z")

</div>

You shouldn’t change the first parameter of lookup, it should remain the unique identifier of that table. In the previous example that Joyce shown, for every field the first parameter in lookup would remain ‘item.data.location.id’ as you use that to find the correct record in other table.

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 14, 2023, 10:24am UTC](https://community.weweb.io/t/display-the-desired-field/3406/8 "2023-07-14T10:24:10Z")

</div>

Here are three columns, in the columns Region and Rooms I use the formula @Joyce . The first time I applied the formula to the Type column.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/604b632c156565ec1c54e4f9871952c7ea950afa.png) I’m not quite sure why the first parameter doesn’t change if the columns are different?

---

<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:** [July 14, 2023, 10:42am UTC](https://community.weweb.io/t/display-the-desired-field/3406/9 "2023-07-14T10:42:22Z")

</div>

There is two parts to the formula:

- Lookup, which is responsible for finding the right row in your table for that corresponding region
- getKeyValue - which is responsible for picking the field that you want to display

Because of this, in lookup you will always want to use the unique field that only relates to the specific item

If you want specific formula help you need to provide more information about how your region table looks

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 17, 2023, 7:02am UTC](https://community.weweb.io/t/display-the-desired-field/3406/11 "2023-07-17T07:02:36Z")

</div>

@luka  
Supabase

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0051e673ab6d431f9c4da835468b74ca460040a9.png)  
Weweb  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/913f4b0b5897a5937339f9d4e3afe6d2c9b43090.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:** [July 17, 2023, 8:30am UTC](https://community.weweb.io/t/display-the-desired-field/3406/12 "2023-07-17T08:30:22Z")

</div>

In the Supabase table you need to find a unique identifier for this table which is ‘id’. With it you can find the exact row you’re looking for before taking any of the data. So instead of Item.data.status it should be item.data.id

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 17, 2023, 8:53am UTC](https://community.weweb.io/t/display-the-desired-field/3406/13 "2023-07-17T08:53:11Z")

</div>

It’s not working.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/663ac643eeca93529cb7bef7a5fc10972bf0ec5f.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:** [July 17, 2023, 9:18am UTC](https://community.weweb.io/t/display-the-desired-field/3406/14 "2023-07-17T09:18:58Z")

</div>

Are the IDs corresponding from one table to another? If not, you need to create IDs that will.

In your first example that worked you had locations ID that matched directly to the IDs in the location table.

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 17, 2023, 10:04am UTC](https://community.weweb.io/t/display-the-desired-field/3406/15 "2023-07-17T10:04:22Z")

</div>

@luka  
I’m totally confused. I have a main table “properties” and other tables that are connected to the main table.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/2abda0e542ca27ed7a029aa686b8976e08436d49.png)  
In WeWeb the Type column is made as @Joyce recommended and everything works there.  
If you don’t mind, let’s take it apart on the basis of “regon” column.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/c/c6e2305fc025b8c9b5d834033cf81ae6757a143a.png)  
This approach doesn’t work with “region”  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/219271136fe5e76d9962b11c80d112b72fc8b8a2.png)  
You wrote that you shouldn’t change the search identifier, but it pulls data from the related table. In this case from the “region” table via the Region column.

---

<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:** [July 17, 2023, 10:46am UTC](https://community.weweb.io/t/display-the-desired-field/3406/16 "2023-07-17T10:46:26Z")

</div>

Can you post a screenshot of the Type and Region tables in Supabase?

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 17, 2023, 10:50am UTC](https://community.weweb.io/t/display-the-desired-field/3406/17 "2023-07-17T10:50:15Z")

</div>

Yes, of course.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/1/19ea6f63c9536ddff3a5deb7b1115f50b47f4f02.png)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/7/7a7b2a06aee7144293a4cfcf45ded68d1222b7b9.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:** [July 17, 2023, 10:59am UTC](https://community.weweb.io/t/display-the-desired-field/3406/18 "2023-07-17T10:59:11Z")

</div>

For the region case, the name of the column you want to display is “name” instead of “region”(last parameter in getKeyValue)

If that still doesn’t work can you try seeing what you get when your formula is only lookup(item.data.region,Region.data) and screenshot what your Region.data collection looks like

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 17, 2023, 2:17pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/19 "2023-07-17T14:17:31Z")

</div>

Unfortunately, it didn’t work  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/a/af94136743dcc92a9a5c98ba9af375b5022766f8.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:** [July 17, 2023, 3:24pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/20 "2023-07-17T15:24:07Z")

</div>

Can you post a screenshot of what happens when you only put lookup(item.data.region,Region.data) in the formula

Also a screenshot of the Region.data collection

---

<div class="post-metadata">

**Author:** ![icos](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/icos/32/4625_2.png) [@icos](https://community.weweb.io/u/icos)\
**Post date:** [July 17, 2023, 3:33pm UTC](https://community.weweb.io/t/display-the-desired-field/3406/21 "2023-07-17T15:33:19Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/b/b5a20bec2cc78320ab4fbab0ff92115aa661e8b0.png)  
All in one screenshot.

[Next page](https://community.weweb.io/t/display-the-desired-field/3406.md?page=2)
