Dynamic Tags in Dataview query - Help?

Hello Folks,

I hope you can help. I am trying to use dataview to indicate links to notes that share a single tag or, if that’s not possible, the first tag in the original note’s YAML tag array.

Things I have tried

list from "Research Notes"
Where contains(file.tags, this.file.tags)

and

list from "Research Notes"
Where contains(file.tags, this.file.tags[0])

AND

list from "Research Notes"
Where contains(tags, this.file.tags[0])

All three of these dataview queries produce a “null” result for me no matter how I structure the tags in YAML.

The following works well but defeats my purpose because I have to indicate the tag I want explicitly.

list from "Research Notes"
Where contains(tags, "yellow")

What I’m trying to do

So, in summary, is there any way to design a dataview list query that will read the note’s YAML tags, separate those tags with OR logic and then run a search for other notes that share one of those tags. If that is impossible, is it possible to read a note’s first YAML tag and then run a search for other notes that share the first [0] tag in the array?

Thank you for the assistance,

Kirt

1 Like

I can see this being a good starting point for a “related” list.

Probably a good case for dataviewjs in combination with a forEach.

Unfortunately, I don’t have much time the next days to investigate, but if you make up a good solution, let us know!

1 Like

FYI: The most recent update to Dataview allows the following to work:

list from "Research Notes"
Where contains(file.tags, this.file.tags[0]) OR contains(file.tags, this.filetags[1])

I’m not sure if this is an innovation or simply a bug fix. Regardless, although it would be great to see a dataviewjs that accomplishes the same thing, the solution above seems to be the most elegant solution for my needs.

Thanks to everyone who read the original post.

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