Passively generated tag-based file relationships viewer

A friendly and helpful person on Discord created the following (and very amazing) dataview query for me to identify “related notes” or, essentially, the tags version of a backlinks menu:

TABLE WITHOUT ID
"[[" + string(file.name) + "]]" as "",
string(filter(flat(map(file.etags, (x) => number(replace(replace(string(contains(this.file.etags, x)), "true", "1"), "false", "0")) * string(x))), (x) => length(x) >= 2)) 
as "Shared tags"
where contains(string(map(file.etags, (x) => contains(this.file.etags, x))), "true") and file.name != this.file.name

This query (1) identifies tags in the active file and (2) populates a table with files that share one of the active files tags and also a second column which identifies the tag in common. Here is an example, where you can see the generated table at the bottom under # Related:

It would be very cool if something like this could be added to the sidebar instead of into individual notes in order to ensure notes contain only content instead of code. It would also save time by not having to add the query to notes one-by-one.

Basically the sidebar menu would automatically (1) identify the active file; (2) identify the tags in the file; and (3) generate a list of related files which share one of the tags. Optionally (4) the tags in common would be identified.

Related

2 Likes

Also related kind of? [Feature Request] List of Links in Side Pane · Issue #104 · TfTHacker/obsidian42-strange-new-worlds · GitHub