Filter to tasks which do not contain a link to any notes from a specific folder

What I’m trying to do

I have a notes folder ‘Milestones’. I’m trying to create a view containing all tasks which do not contain a link to one of the notes in ‘Milestones’. My aim is that all tasks should link to a deliverable, and this should identify those I haven’t linked yet.

Things I have tried

I can link to a single deliverable from the folder (as follows), though I’m struggling to:

  • replace the single ‘Test deliverable’ match with a list of note names
  • find the syntax for ‘contains’ which can compare against multiple values.

TASK
WHERE
contains(text, “[[Test deliverable]]”)

All help appreciated!

If I read your request correctly you’re asking for a task query listing all tasks where none of the outlinks of that tasks goes to a note within "Milestones".

In itself that shouldn’t be too hard, using a combinations of map() and meta() on the outlinks of the tasks. But there is a little bump in the road, and that is that the destination folder of a link is not given in the meta information on the link itself. However, doing a slightly more expensive test you could following the link, and list the file.folder of that file.

An example showing this difference

I placed the following in a note:

- [ ] No link at all
- [ ] To [[Deliverable]]
- [ ] Link to [[Something]] else
- [ ] A link to something [[Non-existing stuff]]
- [ ] Link to both [[Something]] and [[Deliverable]]

```dataview
TABLE WITHOUT ID
  item.text, 
  map(item.outlinks, (l) => meta(l)),
  map(item.outlinks, (l) => l.file.folder)
FLATTEN file.tasks as item
WHERE file = this.file
```

Here the “Deliverable” note is within a sub-folder called “Milestones”, and the other notes aren’t in that folder. In my setup this resulted in this output:

Notice that I do use some trickery, aka FLATTEN, to access each task in a table context.

This leads to the following query to check that none of the outlinks of a task resides within a folder ending with “Milestones”:

```dataview
TASK
WHERE file = this.file 
  AND none(map(outlinks, (l) => endswith(l.file.folder, "Milestones")))
```

Here I use file = this.file AND to limit the query to just my test file. You should most likely exchange that with something to limit to your query to the relevant set of tasks.

You might also want to do something like l.file.folder = "My/Path/To/Milestones" or some other match to limit to your destination folder.

The crucial part of this query is that it map()'s each of the outlinks of the tasks, into a single entity l, where we then do the match against its file.folder parameter. This produces a list of matches, where we’re only interested in the task if neither of the outlinks matches against our folders, so therefore we add a none() around the entire list produced by map().

That’s exactly what I needed, thanks very much.

Really useful example content as well. Lots more to explore.

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