Query on tasks with a hashtag

Things I have tried

What I do right now is for example FROM #JoeSmith, this brings ALL tasks if ANY of them have that so I have a list like.

  • [ ] do this

  • [ ] do the second thing #JoeSmith

  • [ ] do the third thing

Then when I do my query i get all the tasks from this note, I just want to get the 2nd task. It also brings all tasks for any note I’ve put #JoeSmith as a tag in the frontmatter like below, which is probably fine for that


tags: JoeSmith

What I’m trying to do

is it possible using query or dataview to list all tasks from all files that have been tagged with a #?

When you do FROM #JoeSmith you’re targetting the note scope, that is whether that tag exists in the scope of the note. The other scope used by dataview is the list scope, where you can check if a list (or task) item has that tag, and this is reachable through the WHERE clauses.

In your case you could do something like:

TASK
WHERE econtains(tags, "#JoeSmith")

With whatever extra clauses you need to get to your tasks.

PS! Notice that I’m deliberately using econtains here so that it matches the full tag, and nothing but the full tag. This will not match (by choice), tags like #JoeSmithJr or #JoeSmith/something.

1 Like

could have sworn I tried contains(tags, “#JoeSmith”) and had the same issue, but I suspect I was trying them both and probably did not realize I still had something still in place grabbing other. Thank you!

1 Like

As mentioned in my “PS!”, using contains(tags, "#JoeSmith") will include tags like #JoeSmithJr and #JoeSmith/something.

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