View unique outlinks from notes within folder

Dataview Query Questions

First, thank you for taking some time to look at this! I appreciate it a lot.

What am I attempting to do?

I want a dataview query to get the outlinks from all notes within a specific folder. (Meetings in the example data) But, I only want to show the outlinks which point to notes in another specific folder (Resources in the example data) and only show them once in the result.

I’ve been able to get the query to show the outlinks from the notes in the folder that link to the notes of the second folder but I am having trouble making the list/table show only unique results.

My Query so far.

filter(file.outlinks, (x) => contains(x.file.folder, "TEST/Resources")) AS "Meeting Resources"
FROM "TEST/Meetings"
WHERE contains(file.outlinks.file.folder, "TEST/Resources")

The structure of my data.

  • TEST
    • Note_With_Query_In_Question
    • Resources
      • resource01
      • resource02
    • Meetings
      • meeting01
      • meeting02
      • meeting03
    • Fluff
      • fluff01

The outlinks from any note within the Meetings folder that link to notes within the Resources folder is what I want to show in the query results.

filter(file.outlinks, (x) => contains(x.file.folder, “TEST/Resources”)) is accomplishing this in combination with the FROM and WHERE commands. But, let us say that Meeting01 and Meeting02 both contain links to Resource01. The query gives me two results for that link. One link from each of the notes the query found that had outlinks matching the filter.

What I’ve tried so far.

I’ve had a look at:

And at:

for help which has gotten me this far. And I think I might be close to something, and maybe I just need to understand the Filter, Min, and Length Functions better.

Looking over the documentation for Dataview has been helpful but I am still lacking in understanding.



I’ll cut this post off here so it isn’t too long. I thank you for providing any help at all, even if just links to resources that might help me understand this better.


Here is a sample folder that you can put into a vault if you want to see a live version of what I’m attempting to build. (1.6 KB)

A similar use case turned up recently, and I found a solution to make the list of links unique, so it should be possible for you to re-use that script with some adaption (as indicated in the other thread):

Hopefully, this should solve your issue as well! :smiley:

What you have to do is use the FLATTEN and GROUP in DQL.


get unique file.outlinks

      G_OneOutlink AS "Meeting Resources"
FROM "TEST/Meetings"
FLATTEN file.outlinks AS OneOutlink
WHERE contains(OneOutlink.file.folder, "TEST/Resources")
GROUP BY OneOutlink AS G_OneOutlink


Part 1/2

Part 2/2

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