Dataview linking to a file that links to this file

What I’m trying to do

Hey, I’m trying to make a dataview to show a list of files that either links to this file, or links to another file that links to this file

TABLE join(alias, ", ") AS Aliases
FROM "Folder"
WHERE econtains(location, this.file.link) AND contains(tags, "chapter")
OR econtains(location, link(WHERE econtains(location, this.file.link) AND contains(tags, "book"))) AND contains(tags, "chapter")
SORT nation ASC, file.name ASC

The above table doesn’t work, but it’s what I’m trying to do.

So specifically, I want to create a list, which contains every file with the tag “chapter” that links to this file, but also contains every file with the tag “chapter” that links to any file with the tag “book” that links to this file.

Can anybody help me with this? Is this even possible?

Thanks in advance!

Files that links to this file: contains(file.outlinks, this.file.link) (which also in some cases could be written as FROM [[]] but not when you want the alternatives that you do).

A file that links to a file linking to this file: contains(file.outlinks.outlinks, this.file.link)

So the following untested query should target those double links (without looking at chapter or book.

```dataview
LIST 
WHERE contains(file.outlinks, this.file.link)
   OR contains(file.outlinks.outlinks, this.file.link)
```

If you want to combine that with the properties matching, it gets a little trickier…

```dataview
LIST
FROM #chapter
FLATTEN list(filter(file.outlinks, (out) => contains(out.tags, "book"))) as bookLinks
WHERE contains(file.outlinks, this.file.link)
   OR (bookLinks AND contains(bookLinks.outlinks, this.file.link))
```

In theory that should do the trick, but I’m surprised if I didn’t do a typo in that query… :smiley:

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