Dataview Query to exclude incoming linked pages

What I’m trying to do

I’d like to get a list of pages which have a specific tag, but are not linked to the current page already.

example:
page1 - current page I’m working on - tagged #tag
page2 - has a link to page1 but no tags
page3 - has #tag but no link to page1
page4 - has a link to page1 and tagged #tag

I’d like for page3 to be returned by the query.

Things I have tried

Trying to select all from #tag and exclude:

  1. the current page
  2. the outlinks of the page found (i.e. a tagged page) does not contain the current page.
TABLE
FROM #tag
where file.name != this.file.name
where !contains(file.outlinks, this.file)

I’m a little stumped, I tried playing with flattening, but not sure I’m on the right track.
Help would be appreciated.

Hello

Does this do what you need? (It works in local tests when creating the files you detailed in your post, but …)


```dataview
TABLE
FROM #tag AND ![[]]
WHERE file.name != this.file.name
```

1 Like

thank you very much.

1 Like

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