Datview task selection with tags

I have a problem filtering tasks with dataview by tag. Unfortunately I couldn’t finde a solution in the forum.

My goal is to have a list of open tasks where a) a certain hashtag is behind the task or b) in the metadata of the note where the task is written down.

The first condition works fine but the second does not work at all. I use the following code:

TASK
FROM ""
WHERE !completed AND (contains(tags, "#tag/level1")
OR contains(file.tags,"#tag/level1"))
SORT created ASC
GROUP BY file.link
SORT rows.file.ctime ASC

If I use any(contains(file.tags,“#tag/level1”)) instead of contains(file.tags,“#tag/level1”) it shows all tasks where the hashtag appears anywhere in the file (not only in metadata).

Did anyone else had this problem? How can I solve it?

The file.tags and file.etags do refer to all of the tags in any given file, as you’ve discovered. To access just the ones in the properties you could try playing around with file.frontmatter.tags, but be aware that now you’ll need to be aware of whether you’ve used tag or tags and so on, and you’re accessing the raw values, so for most of us this means you’ll look for myTag and not #myTag.

1 Like

Thanks a lot!
The hint with file.frontmatter.tags worked great.

However, it is important to access the raw value in file.frontmatter.tags (without # ).

This topic can be closed.