Dataview: Filter by Keys, which are links

Hey there,

I have a lot of dataview keys like this:

company:: [[Cool Company]]

or

company:: [[Cool Company]] (since 2021)

Now I want to show all employees on the companies-page. I try to do this with the follwing code:

LIST 
WHERE contains(company, "[[Cool Company]]")

But somehow the query only gives me the second result. If the key only consists of the link, it is not shown in the list.

Does anybody know why and what to do?

I’m no expert in dataview, but here is my take. I think this is because the metadata “company” is, under the hood, an array of objects.

In the first case:

company:: [[Cool Company]]

company is an array of “link” objects. To filter on those notes, use contains but without the quotation marks:

LIST 
WHERE contains(company, [[Cool Company]])

In the second case, you are adding the string (since 2021) which casts the type of company to string (instead of link). That’s why the call to contains with the quotation marks works.

My advice is to remove the (since 2021) (put it in another metadata field) and use contain without the quotation marks.

Let us know if it works

1 Like

Thank you for the explanation. I solved it with an OR not to rely on the right input:

LIST 
WHERE contains(company, [[Cool Company]]) 
      OR contains(company, "[[Cool Company]]")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.