Grouping
Table of contents
Basics
Introduced in Tasks 1.6.0.
By default, Tasks displays tasks in a single list.
To divide the matching tasks up with headings, you can add group by
lines to the query.
Available grouping properties
You can group by the following properties:
File locations:
path
(the path to the file that contains the task, that is, the folder and the filename)folder
(the folder to the file that contains the task, which will be/
for files in root of the vault)filename
(the filename of the file that contains the task, without the.md
extension)- Note that tasks from different notes with the same file name will be grouped together in the same group.
File contents:
backlink
(the text that would be shown in the task’s backlink, combining the task’s file name and heading, but with no link added)heading
(the heading preceding the task, or(No heading)
if there are no headings in the file)
Task properties:
status
(Done or Todo, which is capitalized for visibility in the headings)- Note that the Done group is displayed before the Todo group, which differs from the Sorting ordering of this property.
Multiple groups
You can add multiple group by
query options, each on an extra line. This will create nested groups. The first group has the highest priority.
Each subsequent group by
will generate a new heading-level within the existing grouping:
- First
group by
is displayed ash4
headings - Second
group by
is displayed ash5
headings - Third and subsequent
group by
are displayed ash6
headings
See the [[#screenshots | screenshots below]] for how this looks in practice. |
Info
Headings are displayed in case-sensitive alphabetical order, not the original order.
Info
The order of operations ensures that grouping does not modify which tasks are displayed, for example when the limit
option is used:
- all the filter instructions are run
- then any sorting instructions are run
- then any
limit
instructions are run - then finally any grouping instructions are run
Screenshots
Before
Here is an example Tasks result, without any group by
commands:
![[screenshots/tasks_ungrouped.png]]
Tasks not grouped.
After
And here is what this might look like, when grouped by folder, filename and heading:
![[screenshots/tasks_grouped.png]]
Tasks grouped.
Examples
```tasks
not done
group by folder
group by filename
group by heading
```