Dataview - All tasks not completed

 ```dataview
  task 
  ```

This will display all tasks completed and not.

How do I only display not completed tasks?

2 Likes

You can ask to plugin developer in GitHub page (GitHub - blacksmithgu/obsidian-dataview: A complex query language implementation for the Obsidian note-taking tool.).
Since the version 0.3.6 the developer introduced the feature ā€œTask lists now include task context (non-task parents/children)ā€. But none extra information in plugin documentation (https://blacksmithgu.github.io/obsidian-dataview/docs/intro).

EDIT: Thereā€™s some information in the JavaScript API documentation, but I donā€™t have knowledge in JS query language.

I could only find a reference to a ā€œgroupByFileā€ option, which will render the filename containing the task. Iā€™d love to get the header above the task (which is the column name if you use the Kanban plugin).

As I said before, JS is not my ground! :slight_smile:
I see another limitation: children tasks are not filtered.

1 Like

Considering my limitations in the plugin, I suggest two ways:

  1. If you have only ā€˜parentā€™ tasks, you can try something like this:
```dataviewjs
	dv.taskList(dv.pages().file.tasks
	.where(t => !t.completed))
  1. If you have ā€˜childrenā€™ tasks, then you can adopt a ā€˜trickyā€™ solution with css snippets.
  • create a cssclass in frontmatter:
---
cssclass: hidetasks
---
  • write a simple dataview query:
```dataview
	task
  • create a css snippets with this:
/* hide checked tasks */
.markdown-preview-view.hidetasks ul > li.task-list-item.is-checked {
  display: none;
}

This affects all the content of the note with the cssclass defined, that is, all the checked tasks on this note are hidden.

8 Likes

Hey thanks, your first solution:

```dataviewjs
     dv.taskList(dv.pages().file.tasks
     .where(t => !t.completed))
```

works perfectly.

1 Like

I do have a follow up question.
I have a file called ā€œJournal Template.mdā€ with checkboxes that I do not want to appear. Iā€™ve tried this code:

```dataviewjs 
dv.taskList(dv.pages().file.tasks .where(t => !t.completed)) &&
dv.page(!"Journal Template.md")
```

as well as others and it does not work; the check boxes from the ā€œJournal Template.mdā€ keep appearing.

What am I doing wrong?

As I mentioned before, my knowledge in dataview javascript language is almost zero!
Said that, by the logic I think you need to write the ā€˜source conditionsā€™ in the first dv.pages(). Try this:

```dataviewjs
 	dv.taskList(dv.pages("![[Journal Template]]").file.tasks
	.where(t => !t.completed))

(I didnā€™t test thisā€¦)

Well, I appreciate the effort, but that refuses to work.

Sorry, this is beyond my limited knowledge.
I can only suggest this: if your file ā€œJournal Templateā€ is inside one folder that you donā€™t want to include in your search (e.g. folder ā€œTemplatesā€), then you can exclude that folder (and all files inside that folder).

```dataviewjs
	dv.taskList(dv.pages('!"Templates"').file.tasks
	.where(t => !t.completed))
  • If you use the expression ('"Templates"') the search is limited to folder Templates;
  • If you use ('!"Templates"') or ('-"Templates"') the search excludes that folder.
1 Like

Or, returning to the way to exclude a specific file:

```dataviewjs
	dv.taskList(dv.pages().file.where(f => f.name != "Journal Template").tasks
    .where(t => !t.completed))

Thank you, the second one worked. Very helpful.

Iā€™ve found it helpful at times to move the pages() parameter into the where clause, like this:

```dataviewjs
	dv.taskList(dv.pages()
            .file.where(f => !f.path.includes ("foldernamehere")
            .tasks.where(t => !t.completed))
```

Basically it gets all the files for all pages, then filters out anything that doesnā€™t include ā€œfildernamehereā€ in the full path of the file, then filters out completed tasks.

You can also perform other operations on the file component, like ā€œf.nameā€

4 Likes

Thanks for the descriptive explanation. I really appreciate that.
Iā€™m a newbie in all this stuff (code languages, etc.) trying to capture some information for my own use of Obsidian.
The Dataview plugin has a tremendous potential. But for ā€˜non-codersā€™ the approach is no easy.
For now the generic approach (dataview) is less complex and more or less accessible through the plugin documentation. But the approach via javascript (dataviewjs) is much more complex and the plugin documentation is very uncompleted for ā€˜code-newbiesā€™. Much complex but certainly more rich in potential.
In my personal use I donā€™t use (yet) this approach because all these limitations. I want to but the learning curve is in another level. This help call was a pretext to start this (long) learning.
Thanks.

EDIT: Just one question: when you write ā€œfoldernamehereā€ works too with ā€œfilenamehereā€?

1 Like

You might consider using the Tasks plugin - much easier to use for filtering tasks various ways.

1 Like

Thanks for posting this! I didnā€™t know you could filter at the task level inside a dv.taskList(). Super helpful!

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