Using a dataview query how do you display only those tasks which have a value for some field?

Things I have tried

What I’m trying to do

Write a dataview tasks query that returns only the task that have a value for some attribute. E.g. due

Hi @Adamson, are your fields written in the dataview style? E.g.

- [ ] this is a task [myField:: breakfast] with a field
- [ ] this is a task with (myField:: dinner) a field

(Or for the field due specifically, instead of some field with a custom name, there’s a third way of annotating it with an emoji shortcut documented on the page.)

If so, I imagine you’ll want a task query that looks something like:

FROM "MyFolderIfThereIsOne"
WHERE myField = "dinner"

You can replace the folder name in the FROM with a filename (also in quotes) or a tag name (not in quotes) or various other options to describe the files you are looking for tasks in. Or you can remove the FROM line entirely to search the whole vault.

The WHERE allows you to filter on your field, I showed an example for filtering on a specific value; you can also search for the field’s existance in the task with WHERE myField != null or if your field potentially contains multiple values:
WHERE contains(myField, "dinner") instead of = "dinner" which expects an exact match.

If you need further help/clarification, please share what TASKS query you tried, what happened when you tried it (error message? blank results?) and what an example task you want to find looks like!

Thanks @scholarInTraining

1 Like

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