New Obsidian user here. After months of feeling lost in the woods, I can see a strategy emerging that will greatly accelerate my workflow and it’s absolutely intoxicating (aside: whenever I get frustrated in such woods, I read this). Anyway, I feel like I have finally done enough research on my own to ask others to help!
What I’m trying to do
- Be able to show all notes that have a specific tag in the frontmatter (“tags” field) that is also in the frontmatter of the current note. [I use this approach for notes entirely related to that tag]
---
tags: project1
---
- Be able to show all bullets across all notes that have a specific tag appended to it [I use this approach for notes not entirely related to that tag such as daily notes]
- Remember this nugget #project1
Key to this… In both instances, I don’t want to have to specify the tag in my dataview code, because I’m applying the code via templates to many different notes. I want the code to reference whatever tags I have added to any file’s frontmatter.
Things I have tried
Thanks to this forum, I’ve pulled together dataview code that solves item #1 above.
TABLE summary
WHERE any(contains(file.frontmatter.tags, this.file.frontmatter.tags))
Great, but item #2 (the bullets query) is where I’m getting stumped.
I DO have working code that shows me all the bullets in any note that has a specific tag appended to it.
LIST WITHOUT ID item.text
FLATTEN file.lists as item
WHERE contains(item.tags, "#project1")
SORT date DESC
This gives me the view I want, but as mentioned, I don’t want to have to hardcode the specific tag. So, I figured I would just add the WHERE condition from the Item #1 solution like this…
LIST WITHOUT ID item.text
FLATTEN file.lists as item
WHERE any(contains(file.frontmatter.tags, this.file.frontmatter.tags))
SORT date DESC
That doesn’t work. It shows all bullets (whether I added the #project1 tag to them or not), and only from notes with a tag in the frontmatter matching the current file’s frontmatter, thereby ignoring all the other bullets out there that have the tag appended to it.
So, next I tried to replace the tag name in the working bullets query above with “this.file.frontmatter.tags”. So, like this…
LIST WITHOUT ID item.text
FLATTEN file.lists as item
WHERE contains(item.tags, this.file.frontmatter.tags)
SORT date DESC
That doesn’t work either. (In fact, it spawns the dreaded everything-in-your-vault result, so I have to wait for 20 seconds while Obsidian renders the entire universe )
Any help getting me to the finish line with this is greatly appreciated!