Filter Tasks by one tag shows multiple tasks with different tags


got some issues with filtering Tasks via dataview :wink:

What I’m trying to do

I am trying to show tasks from various notes filtering these based on a specific tag (#test/tag)

Things I have tried

It works as far as it takes existing tasks from different notes – however, when I have a list of notes in a file, the dataview filter takes all existing tasks beneath the first task with a tag,m even though they have different tags.
For example:

List of todos in specific note file:

  • [ ] Funding Project A #test/tag
  • [ ] Testtask #anothertest/tag

Dataview Code:

     WHERE contains(file.tags, "#test/tag") AND !completed


  • [ ] Funding Project A #test/tag
  • [ ] Testask #anothertest/tag

So dataview seems to be listing anything below the correct tags, whether it has the correct tag or not.

Same happens using this code:

FROM #test/tag   
WHERE !completed

What am I doing wrong?

Any joy with this?

     WHERE contains(text, "#test/tag")
     AND !completed
1 Like

Yep, that works, thanks
…but why would it not work with contains(file.tags, "#test/tag") ?

I thought that file.tags would cover the same and actually being more intended for it.

1 Like

Good to hear.

I think it is because tags are note-level metadata, i.e. they apply to an entire file and cannot be isolated.

With text, we can isolate words as list-level or task-level metadata, which means we can ask Dataview to query the tag as if it were text only and therefore extract just the lines of data that we need. I think your original way makes more sense, but …

That’s my understanding of things, but I am a novice when it comes to Dataview.


That makes a lot of sense and clarifies the situation quite a bit – thanks a lot!

1 Like

Absolute pleasure. Just did some re-reading. Perhaps this:

Tags are a source.

Text is a field type.

My head :exploding_head:


In a TASK query there is also a difference between file.tags and tags, where the first refers to all tags related to the file, and the second refers to the tags of a given task. Incidentally the use of text also refers to just a single task. (If I’m not mistaken)

1 Like

So this works:

     WHERE contains(tags, "#test/tag") AND !completed

Learn and live :rofl:

Sorry, OP.


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