Dataview TASK not always working at a single task level

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I’m trying to use dataview for getting a list of tasks that contain a link to the current note. Those tasks might be contained in another note(s) intermixed with other tasks referencing other notes.

Things I have tried

I have a note containing something like this:

  • call [[John]] as soon as possible
  • talk to [[Ross]] about the expenses

and another note named after [[John]] with this snippet:

TASK
FROM [[#]]

This gives back both tasks from the first note, because (apparently) while the TASK Dataview query works at the single task level (one line), the FROM condition returns the full list of tasks in a note containing [[John]], not only the single task naming it.

It might seems a little counter intuitive but the FROM works on a page/note level even, so it correctly includes all files having any outlink to [[John]]. To further restrict the query, you need to check the outlinks of the task itself.

So try the following:

```dataview
TASK
FROM [[]]
WHERE contains(outlinks, [[]])
```

Thanks a lot this need to be documented in manuals, works perfectly!

1 Like

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