# Query or Vlookup similar method

**URL:** <https://community.fibery.io/t/query-or-vlookup-similar-method/1816>\
**Category:** Get Help\
**Created:** [July 19, 2021, 1:21pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816 "2021-07-19T13:21:25Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sohee](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sohee](https://community.fibery.io/u/sohee)\
**Post date:** [July 19, 2021, 1:21pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/1 "2021-07-19T13:21:25Z")

</div>

Hi community,

I have 2 Types as follows

`Fund Information` Type with 2 fields

- Ticker
- Fund Name

`Fund Metadata` Type with 3 fields

- Ticker
- Type of Metadata
- Meta

`Fund Information` is related to `Fund Metadata` as `1:n`

I want to create a new field in `Fund Information` Type that lookup the content of `Meta` field in `Fund Metadata` Type that satisfies 2 conditions:

- `Fund Information`.`Ticker` is the same as `Fund Metadata`.`Ticker`
- have a specific value in `Type of Metadata` field

A pseudo query of my needs

```sql
SELECT Meta 
FROM Fund_Metadata
WHERE Fund_Metadata.Type_of_Metadata = "my_criteria" 
    AND Ticker = Fund_Metatadata.Ticker

```

Currently, I’m doing a hacky way like this in Fibery.  
I create a new formula-type field named `Tmp` in `Fund Information` Type

> [Fund Metadata].Filter(([Type of Metadata].Name = “Auditor”) and (Ticker = [Fund Information].Ticker))

Then I create another formula-type field in `Fund Information` Type, in order to retrieve the content from `Meta` field in `Fund Metadata` that satisfy my 2 conditions.

> [Tmp].Join(Meta,“,”)

I want to ask if someone know a proper way to implement this task in Fibery?

Thanks

---

<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 19, 2021, 1:57pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/2 "2021-07-19T13:57:52Z")

</div>

I think you are doing it ‘the proper way’ 🙂  
But there’s actually no reason why you need to use two fields. You should be OK to combine the filter and join functions:  
`[Fund Metadata].Filter(([Type of Metadata].Name = “Auditor”) and (Ticker = [Fund Information].Ticker)).Join(Meta,",")`

---

<div class="post-metadata">

**Author:** ![sohee](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sohee](https://community.fibery.io/u/sohee)\
**Post date:** [July 19, 2021, 2:12pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/3 "2021-07-19T14:12:11Z")

</div>

Yeah. I tried to combine field like what you mentionned. But it doesn’t work.

Fibery doesn’t allow to finish the formula with the error

> Sorry, can’t convert the Fund Metadata formula to Text — please create a new formula instead.

---

<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 19, 2021, 2:31pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/4 "2021-07-19T14:31:04Z")

</div>

You can’t change the return datatype of a formula once it has been created, so you will need to create a new formula field from scratch.  
Your Tmp formula is returning a collection of ‘Fund metadata’ entities, whereas the join formula is returning a text string.

---

<div class="post-metadata">

**Author:** ![sohee](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sohee](https://community.fibery.io/u/sohee)\
**Post date:** [July 19, 2021, 3:18pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/5 "2021-07-19T15:18:36Z")

</div>

Thanks again for you explanation.  
Yes. It works by creating a new field from scratch and combining the formula.  
Though I hope someday Fibery will have a more intuitive way to do query like this 😃

---

<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 19, 2021, 3:35pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/6 "2021-07-19T15:35:58Z")

</div>

Glad it worked 🙂  
Not sure why you think this method is ‘hacky’ or not intuitive, but I guess intuition varies from person to person and depends heavily on previous experiences/tools used 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![sohee](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sohee](https://community.fibery.io/u/sohee)\
**Post date:** [July 19, 2021, 4:33pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/7 "2021-07-19T16:33:33Z")

</div>

Agree with your perspective. As my point of view, I expect that having a proper Query formula like in Google Sheet where you can do query with `Select ... Where ...` is much more intuitive than what I currently do in Fibery for an equivalent output of a query statement.

---

<div class="post-metadata">

**Author:** ![antoniokov](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/antoniokov/32/201_2.png) [@antoniokov](https://community.fibery.io/u/antoniokov)\
**Post date:** [July 20, 2021, 12:19pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/8 "2021-07-20T12:19:58Z")

</div>

I wonder: do you expect the query to get precisely one `Fund Meta` or could there be many of them?  
For this reply, I’ll assume it’s a single Entity that you are looking for 🙂

1. How is the Ticker related to `Fund Information`? If it’s 1:1, I think you could reorganize things to skip the extra `Ticker = [Fund Information].Ticker` filter.
2. Once we add `First()` function (🤞 this August), the solution would be a single Formula: `[Fund Metadata].Filter([Type of Metadata].Name = “Auditor”).First().Meta`.

Please feel to correct my assumption and comment on this approach.

---

<div class="post-metadata">

**Author:** ![sohee](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sohee](https://community.fibery.io/u/sohee)\
**Post date:** [July 20, 2021, 3:01pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/9 "2021-07-20T15:01:23Z")

</div>

Yes. I expect the query to get a single one `Fund Metadata`

> [@antoniokov](#):
>
> How is the Ticker related to `Fund Information` ? If it’s 1:1, I think you could reorganize things to skip the extra `Ticker = [Fund Information].Ticker` filter.

→ `[Fund Information].Ticker` related to `[Fund Metadata].Ticker` as `1:n`.

Since I doubt that I explain correctly the entity relationship, you can find here my app. Tell me when you are done with investigation, so I stop sharing.

> [https://shared.fibery.io/t/8eff79c3-a798-42c4-8e23-c322104d7ddd-investment-fund-wiki](https://shared.fibery.io/t/8eff79c3-a798-42c4-8e23-c322104d7ddd-investment-fund-wiki)

> [@antoniokov](#):
>
> Once we add `First()` function (🤞 this August), the solution would be a single Formula: `[Fund Metadata].Filter([Type of Metadata].Name = “Auditor”).First().Meta` .

→ Well I’m glad to learn more about this new function in August then 😃

Thanks for your time

---

<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 20, 2021, 3:16pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/10 "2021-07-20T15:16:54Z")

</div>

The Ticker field in Fund Metadata is a lookup of the Ticker field in Fund Information, so you definitely don’t need the logic to check it.  
Until the `First()` function is released, you should be fine with:  
`[Fund Metadata].Filter([Type of Metadata].Name = “Auditor”).Join(Metadata,"")`  
as long as only there is only one Metadata entity of the type Auditor for each Fund Information entity.

---

<div class="post-metadata">

**Author:** ![sohee](https://avatars.discourse-cdn.com/v4/letter/s/278dde/32.png) [@sohee](https://community.fibery.io/u/sohee)\
**Post date:** [July 21, 2021, 6:23pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/11 "2021-07-21T18:23:27Z")

</div>

Thanks for taking time to investigate.  
It works exactly like what you said (omitting the `Ticker` logic checking part)

If possible, could you please explain to me the underlying logic in Fibery how can this work?  
In my understanding, I need to check 2 conditions, so the `Filter` formula should have 2 condition-logic-check, like what a `SELECT` query should do. But within Fibery, I need only 1 condition for `Filter` formula

---

<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 21, 2021, 6:49pm UTC](https://community.fibery.io/t/query-or-vlookup-similar-method/1816/12 "2021-07-21T18:49:01Z")

</div>

The Ticker field in the Fund Metadata type is merely a [lookup](https://help.fibery.io/en/articles/3908489-lookup-field). This means that it is automatically calculated from the Ticker field of whichever Fund Information entity the Fund Metadata entity is associated with.  
It will therefore always be the same value, so there is no need to check if they match.
