Dataview list tasks from notes with certain metadata properties

What I’m trying to do

Is it possible to use dataview to list tasks from notes with certain metadata properties? For example, I would like a list of tasks from notes where there is

status: InProgress

in the metadata

Things I have tried

I tried

task
where status = "InProgress"

but to my understanding, when getting a task list, the “where” query is to check for task completion.

I know I can do something similar to

task
where contains(tags, "#inprogress")

but this requires me to tag every task, which I don’t want to do.

I have looked on the forums and google as well as the dataview documentation, but haven’t found anything that would help me achieve what I want.

If the status is stored as a tag in the YAML header, you can query pages that contain the tag and have tasks. In the image below:

  • the pages called task 1 and task 2 don’t have a tag in the YAML header
  • the pages called task 3 and task 4 do have a tag (InProgress) in the YAML header
  • from the query on page 1, you can see that only the tasks from the tagged pages are listed

Does this do what you want?

https://blacksmithgu.github.io/obsidian-dataview/reference/sources/

1 Like

Yes this is what I want to do thank you! Is it only possible to accomplish this with tags? While I don’t mind doing it this way, I don’t usually use tags.

Thanks so much!

1 Like

It is the only way I know of – extracting data from one of the sources available through Dataview:

https://blacksmithgu.github.io/obsidian-dataview/reference/sources/

Perhaps someone else will have a better solution.

Thank you so much for your help!

1 Like

What do you mean by this? The where query can be uses against all metadata, and in a task context it starts out related to the task itself, but you can also query file metadata.

How did you declare the status? Was it in a frontmatter block? Was it in the body of the note?

For tasks, I’ve only seen it used in most examples for getting tasks that are completed or not (!competed vs completed) and used with file.day, but I’ll admit I’m not an advanced user of dataview. status was declared in the frontmatter block

for the example I gave above

task
where status = "InProgress"

if I change task to list, it works, but with task it says there are no results for the query

Try the following in a file of its own:

---
Zstatus: InComplete
status: InComplete
---

- [ ] my task
- [x] with status "x"

## Base query

```dataview 
Task
Where file = this.file
```

## status
```dataview 
Task
Where file = this.file
WHERE status = "InComplete"
```

## zstatus
```dataview 
Task
Where file = this.file
WHERE zstatus = "InComplete"
```

## file.frontmatter.status

```dataview 
Task
Where file = this.file
WHERE file.frontmatter.status = "InComplete"
```

## x status

```dataview 
Task
Where file = this.file
WHERE status = "x"
```

This file in reading view displays as the following for me:

Explanation:

  • status in a Task query refers to the character within the square brackets
  • zstatus doesn’t have a special meaning so it refers to the frontmatter field of the file
  • file.frontmatter.status specifically targets the frontmatter variant of the status field

For other implicit metadata of a Task query see Metadata on Tasks and Lists - Dataview

Sorry for not catching the special meaning of status in a Task query earlier, it just slipped my mind.

I edited it a little bit, but this code was what I was looking for (specifically the file.frontmatter.status). Thank you!

1 Like

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