What I’m trying to do
Dataviewjs query tasks matching a particular tag and any nested/subtags—ideally whether or not it has any matching parent tags.
example: if the tag is WANTED,* tags such as #tag/WANTED
, #tag/WANTED/subtag
, #other-tag/WANTED
, or #other-tag/WANTED/subtag
, would all be included in the results.
Things I have tried
task.tags.contains("WANTED")
task.tags.contains("#tag/WANTED")
task.tags.includes("#tag/WANTED/")
- other forms such as icontains, tag.contains, etc. — errors
In context, from a dataviewjs query in my vault:
const tCount = dv.pages("")
.file.tasks.filter(task =>
task.tags.contains("⛑️")
&& !task.completed)
.length;
I know I have at least one task that matches: incomplete & tagged “#for//
”, but tCount comes back as 0, so I can’t proceed any further. (In that particular case, I have a tasks plugin callout which is shown or not shown depending on the tCount being 0 or not.)
It doesn’t seem to follow a regular dv query, which does show the subtagged task.
```dataview
task
where !completed AND contains(tags, "⛑️")
Result:
- [ ] order medicine
#for/⛑️/💊