Showcase basic syntax of TASK Queries
Basic Task Queries¶
Basic¶
Relationship between Tasks and Pages
The TASK
query type is special, because unlike all other query types (LIST
, TABLE
, CALENDAR
) TASK
does not operate on page level but on task level. If a page contains three tasks, you'll get back three results instead of one, like you'd get with any other query type. This allows us to filter for task specific properties, like included tags, meta data or text. Be aware though, that every task inherits all properties from the page it's in. Read more about how task queries behave and what for information you have available.
List tasks from a folder
TASK
FROM "10 Example Data/assignments"
List tasks from a tag
TASK
FROM #next
Combine multiple tags
TASK
FROM #clientC OR #clientB
Combine multiple folders
TASK
FROM "10 Example Data/assignments" OR "10 Example Data/games"
Combine tags and folders
TASK
FROM "10 Example Data/assignments" AND #later
List all tasks, everywhere
Add dataview
to code block
The output of this is pretty long. If you want to see it, add dataview
to the code block - like on the examples above!
TASK
Variants¶
List only open tasks¶
TASK
FROM "10 Example Data/assignments"
WHERE !completed
Group tasks by file¶
TASK
FROM "10 Example Data/assignments"
GROUP BY file.link
Show tasks that have a certain tag¶
TASK
FROM "10 Example Data/assignments"
WHERE contains(tags, "#later")
Show tasks with a due date (a task-located meta data field)¶
Meta data on task level
You can add meta data on tasks via the inline meta data syntax, i.e. [duedate:: 2022-09-09]
- or [contact:: Petro]
. Just be sure to wrap it into square brackets, so that data view can interpret it correctly.
TASK
FROM "10 Example Data/assignments"
WHERE duedate
Sort task after completion date¶
Only possible with designated meta data
A task does not know its completion date out of the box. In order to query for it, you need to add it to the task as an inline meta data field. Dataview provides an automatism for this: In the dataview options, at the very bottom, activate "Automatic Task Completion Date" to automatically append a completion date when checking a task.
⚠ Attention! Dataview can only add this information if you check a task inside a dataview output - meaning inside a TASK Query!
TASK
FROM "10 Example Data/assignments"
WHERE completed
SORT completion
Advanced usage
Do you want to see more advanced examples? Head over to the Query Type Overview to see all available TASK queries in the vault!