I’m trying to produce a list of notes related to the current note, connected by a frontmatter list. My goal is to have a meeting notes template where I can connect the current meeting to other meetings in the same series or on the same topic.
I have frontmatter for series (a single value string) and topics (a list).
In my query result, I’d like to see:
meetings that share the same name ( done)
meetings that share the same series string ( done)
meetings that have have at least match between topics lists ( this is my problem)
It’s ok if it’s multiple queries, but all-together would be nice.
Things I have tried
To start, my meetings all follow the naming convention YYYY-MM-DD {{meeting title}}
Frontmatter includes:
```dataview
LIST FROM #meeting
WHERE substring(file.name,11) = substring(this.file.name,11)
OR file.frontmatter.series = this.series
AND file.name != this.file.name
SORT file.name DESC
```
Here’s what I think should work, but doesn’t:
```dataview
LIST FROM #meeting
WHERE any(map(this.frontmatter.topics, (x) => contains(file.frontmatter.topics, x)))
AND file.name != this.file.name
SORT file.name DESC
```
This returns an empty list.
I expected this to take this.frontmatter.topics and map the individual list values (x) to the function contains(file.frontmatter.topics, x). I’d then get back a long list of [true...false...true] for the given file, and any true would do.
Could you show the topics of a few files not being displayed as expected for that last query? (Preferably from source mode and as text)
The query looks OK for starters, so I’m wondering if there is a property issue somehow. The one thing I’m concerned about though is the use of file.frontmatter.topics and not just topics (and this.topics), as you force a raw handling of the topics when prefixing with file.frontmatter.
My working query above (the one with file.frontmatter.series = this.series) shows the second file (matching on series). But the query with the map function doesn’t return the second file.
I expected the the map function to yield contains(file.frontmatter.topics, "SEL"), which does yield the right result).
I’ve also tried quotes around the multi-word topics (“Powdered Donuts”) and indenting the lists with 2 and 4 spaces, but those changes didn’t seem to make any difference.
Another followup this morning because I actually read the rest of your reply this time. Your suggestion to avoid file.frontmatter was spot on. Here’s my modified query that works.
```dataview
LIST FROM #meeting
WHERE any(map(this.topics, (x) => contains(topics, x)))
AND file.name != this.file.name
SORT file.name DESC
```
The result of this query is a list of every note that contains at least one topic that matches at least one topic from the current file.
So now I’ve combined all my conditions into a single query:
## Related Meetings
```dataview
LIST FROM #meeting
WHERE (
substring(file.name,11) = substring(this.file.name,11)
OR series = this.series
OR any(map(this.topics, (x) => contains(topics, x)))
)
AND file.name != this.file.name
SORT file.name DESC
```