Dataview - List All Notes Containing Links to Notes With Specific Tag

What I’m trying to do

I currently have note for each of my contacts, e.g. “Mark”, “Pete”, “Helly”. Within each of these contact notes, I have various tags. For example, the note for “Mark” contains the tag #programmer.

From time to time, I create separate notes recording conversations I have with my contacts. If I have a conversation with Mark, I create a new note and a link within that note to [[Mark]].

What I would like to do is use dataview to create a list of all conversation notes which have a link to a contact with a certain tag.

For example, I’d like to make a like of all conversation notes linked to people with the #programmer tag. So, any conversation note containing a link to Mark would appear on this list, because his contact note contains the #programmer tag.

Things I have tried

I have searched this forum for similar requests, but so far all I can create is a list of notes containing the #programmer tag itself. I need a list of notes containing a LINK to other notes which have that tag!

Hopefully that all makes sense. Thanks very much for any help!

How do you define a contact, and/or conversation note?

The end query will need to look into each of the file.outlinks to check whether that has the wanted tag, but in order to give a good example it would be nice to see your current query which lists conversation notes with/without contacs. And now how you differentiate between those kind of notes.

All contact notes are located in a folder called “Contacts”, and all conversation notes are located in a folder called “Call Notes”.

My current query is as follows:

LIST
FROM "Call Notes" AND #programmer

However, this only pulls in call notes where I have explicitly added the #programmer tag. And I don’t want to have to do this for every call. So, if I can only add a link to Mark’s page, I’d like for that call note to appear when I search for #programmer.

thanks!

The following is untested, but might do what you want:

```dataview 

LIST
FROM "Call Notes"
WHERE length(filter(file.outlinks, 
  (link) => startswith(link.file.path, "Contacts") 
        AND contains(link.file.etags, "#programmer")))
```

This worked perfectly. Thank you!

1 Like