Dataview query of tasks with tag matching current file property

What I’m trying to do

I want to create a dataview query of all tasks in a vault that contain a tag matching a frontmatter metadata property in my current file. For example, I may have a note in my vault with the following tags:

- [ ] Complete project #john-doe
- [ ] Call project leader #jane-doe

Then in a separate file that has a front matter property of “person: john-doe”, I want to query all tasks in my vault that have a tag matching that “person” property.

Things I have tried

I’ve attempted the following query, but it doesn’t return any results:

where contains(tags, this.file.person)
and !completed

When I query tasks with the person’s name hardcoded into the query, it works. But when I attempt to use the this.file.person variable, it doesn’t return anything.

I’ve also tried putting the person’s name as a tag within the file’s front matter metadata and querying against that. Example:

where contains(tags, this.file.tags)
and !completed

When I do this, the query appears to return many unrelated tasks.

Thanks in advance.

Hi @sempervarius, welcome to the community!

The first place I’d look is at this.file.person. I don’t think that will work. I think you need to use this.person instead.

Here’s what it looks like on my system:

That worked! Thanks so much.

1 Like

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