Filtering pages using DataviewJS, where a property is a file link

I’m trying to filter through pages by looking at the properties, basing my search on the company this person is working for.

Here’s my example file, with the title “Bob Vance”:

---
tags:
  - person
company: "[[Vance Refrigeration]]"
---

This means that the company property’s value is a link to the “Vance Refrigeration” note. I want to pull all notes where the company property equates to that value.

I’ve tried this, I feel like this should work, based on everything I’ve looked up:

```dataviewjs
dv.span(dv.pages("#person").where(p => p.company == "[[Vance Refrigeration]]"))
```

In fact, if I change the property of the Bob Vance note to be company: "Vance Refrigeration", and remove the brackets in the dataviewjs query accordingly, it retrieves that note just fine.

I’ve also tried different variants of escaping the brackets or quotes in the DataviewJS query, but nothing’s working. Is there some kind of function I need to be calling when the property’s value is a file link, or have I just not figured out the proper way to escape the brackets?

There’s probably another/better way (:sweat_smile:) but this seems to work:

```dataviewjs
dv.span(
  dv.pages("#person")
  .where(p => dv.func.contains(p.company, dv.func.link("Vance Refrigeration")))
)
```
2 Likes

Hey, I’ll take it! Works like a charm!

1 Like

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