Skip to content

Possible to query tasks only from files with certain tags [in frontmatter]? #442

Answered by claremacrae
ennenine asked this question in Q&A
Discussion options

You must be logged in to vote

This is not currently possible in Tasks directly, but we can get dataview to do the search for us and create a Tasks query.

```dataviewjs
const tag = '#examples'
const matching_files = dv.pagePaths(tag)
if ( matching_files.length > 0 ) {
    const query = `
        not done
        (path includes ${matching_files.join(') OR (path includes ')})

        # you can add any number of extra Tasks instructions, for example:
        group by path
`;

    dv.paragraph('```tasks\n' + query + '\n```');
} else {
    const message = `No files found with tag ${tag}`
    dv.paragraph(message)
}
```

You need to enable 'Enable JavaScript Queries' in Dataview's settings.

Credit: jonlemon in
https://forum…

Replies: 7 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@therden
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@claremacrae
Comment options

@willow512
Comment options

Answer selected by claremacrae
Comment options

You must be logged in to vote
1 reply
@claremacrae
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
scope: tags Anything to do with tags, both as `#` and in YAML frontmatter
6 participants