Goal: a shorter, easier to read, but still comprehensive, to-do list.
I want a list of all tasks in my vault that are not complete. Note that I use Obsidian’s built in task feature, not a plugin, to create tasks in my notes.
Things I have tried
I am able to use Dataview to create a list of all tasks in the vault that are complete using this code:
```dataview
task
WHERE completed
```
However, when I try what I believe to be the opposite code:
```dataview
task
WHERE !completed
```
I get both the uncompleted tasks, and their associated complete nested sub-tasks. (It correctly filters out any completed tasks that are not nested). The nesting is achieved by putting a tab before the the brackets that cause Obsidian to decide that the row is a task.
Is there a way to set up my code to also remove the completed sub-tasks from my list, or do I need to live with it showing the completed sub-tasks?
I had the same problem a few days ago, but luckily, I wanted to filter out a task with a date.
```dataview
TASK
FROM ""
WHERE !completed AND contains(text, "(@")
```
So, with AND contains(text, "(@")), I get all and only uncompleted tasks that start with a date like (@27. 06. 2025). Without that part, I get a list of all, completed and uncompleted tasks.
I know it doesn’t answer your question, but just as an idea, if you can implement it in your case.
Hmmm, I just tried your solution, and, since I have no tasks that have the @ symbol I got the “no results to show for task query” result. But if I change that @ to a letter or combination of letters I do still, sometimes, get both completed and uncompleted tasks. It still appears to have to do with nested tasks. If I use “z” as the text to search for, I get exactly two uncompleted tasks, that contain the letter z, and nothing else.
However, if I use “a” for the letter I get both completed and uncompleted tasks, where the top level contains the letter a and is uncompleted, but some of the sub tasks are complete, and some of them do not contain the letter a (indeed, I get subtasks in all four states:
complete, with at least one a
incomplete, with at least one a
complete, no "a"s at all
incomplete, no "a"s at all
I also tried another string, “SEAD”, which occurs only in two tasks, and this gave me all tasks that occur in a note in which “SEAD” appears in one task, including all of the tasks in that note that do not have that string of letters. So, clearly, the “contains” part of the argument is concerned with the whole note, not the task.
Therefore, I wonder if the fact that your work around worked for you is simply luck. If you want to try testing this, try putting a @ or a date somewhere else in a note that has a completed task, and see if it makes it appear in your list. If you try this, please let me know what happens, I am curious.
Dataview task queries defaults to always include subtasks if available. This means that if you filter matches a task, which has subtasks, it’ll display the task with subtasks regardless of whether the subtasks matches the filter or not.
Thanks! I will try to find posts on CSS and see if I can find something useful for this case. I suspected that it was a case of all subtasks come along for the ride no matter what, from the behaviour, but couldn’t guess if there would be a workaround or not, which is why I asked.
It was my mistake; I didn’t understand the main problem - subtasks! I don’t have those in my case.
I believe that @holroy’s solution will give you what you want.
I was afraid to try this, that you don’t bring bad luck to my “formula” … done, still worked. But, as I mentioned, I don’t have subtasks.