Dataview for tasks excluding "other tags"

Things I have tried

I have tried !contains(tags, “”)

What I’m trying to do

I am trying to grab a list of tasks related to an [[Example Project]] without any tags so I can add it to the list of tasks that are tagged, so I may have a meeting for a project and a task list my look something like this:

  • Open Task #1
  • Open Task #2 #ExampleProject
  • Open Task #3 #NewProject
  • Open Task #4 #NewProject #ExampleProject

I’m able to pull all 4 tasks easily, ideally I’d like to only pull tasks 1, 2 and 4
Anything with the #ExampleProject Tags and anything without a tag.

My dataview query got pretty complicated pretty quick :slight_smile:

TASK
WHERE contains(tags, "#ExampleProject") AND !completed
OR contains(Project, [[Example Project]]) AND !completed
OR contains(Project, [[Example Project]]) AND !contains(tags, "") AND !completed

First of all remove the hashtag in #1, #2, … It trips up dataview, it seems.

Then try the following:

```dataview 
TASK
WHERE file.name = this.file.name 
WHERE (length(tags) = 0
   OR econtains(tags, "#ExampleProject"))
```

Replace the first WHERE clause with something matching your project, and note the usage of econtains to ensure the project name isn’t a prefix of some other project tag.

1 Like

Thanks I will take a look at this, the #1, #2, were just to be able to describe which I want, I dont have any other tags!

Thanks this worked for the most part!

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