Filtering Dataview with Obsidian Properties of type list containing links

to query in dataview properties of type “list” I use contains(type, “book”)
but it doesn’t work for list of links

What I’m trying to do

let’s have a note with following yaml fields (properties):

parent:
  - "[[aa]]"
  - "[[bb]]"
papa:
  - aaa
  - bbb

when I do

list where contains(papa, "aaa") 

I get the note
But
when I do

list where contains(parent, "aa") 

I don’t get the note

Please help me: do I something wrong? (I also tried with contains(parent,“[[aa]]”)

Things I have tried

Try any of this:

Having a note with these properties:

---
p1:
  - [[aa]]
  - [[bb]]
p2:
  - cc
  - dd
p3:
  - "[[ee]]"
---

All of these queries will get you the note:

```dataview
list 
where contains(p1, "bb")
```
```dataview
list 
where contains(p2, "cc")
```
```dataview
list 
where contains(p3, [[ee]])
```

In earlier versions of Obsidian and Dataview the treatment of [[aa]] within the frontmatter had slighlty different meaning, so if you’re interested in the nitty-gritty details, I’ve tried an explanation in the following answer on a very related topic:

So basically your parent is an actual list of links, while the papa is just a list of texts. This means that when you want to compare against either you need to make sure you’re comparing apples to apples, so to speak.

So the latter example could be written in all of these variants (and surely more):

```dataview
LIST WHERE contains(parent, [[aa]])
```

```dataview
LIST WHERE contains(parent, link("aa"))
```

```dataview
LIST WHERE contains(string(parent), "aa")
```

Where I would recommend the first two variants in most cases, as they compare links against links. The difference between those two is just related to two different ways of denoting a link in a DQL query. The latter one can be useful in some cases where you’re not sure if your list is actually links or texts, as it converts any links to their text equivalent.


On a sidenote, if you might change which link you want to compare against, that being renaming that link or similar, you might want to use this query variant:

---
linkToMatch: "[[aa]]"
---

```dataview
LIST WHERE contains(parent, this.linkToMatch)
```

This is, so far, the only variant in this thread that would detect and correct itself related to renaming the aa file.

1 Like

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