Creating a dataview query to filter inlinks

What I’m trying to do

I want to use dataview to display all incoming links to a file, which for the metadata field type contain the value Project.

Things I have tried

I am trying to use FLATTEN and a combination of list() and filter() to extract the valid file links. I copied the approach by @holroy from this topic: Dataview inlinks behaviour help

This is the query I am trying to use:

TABLE WITHOUT ID
file.link as Quarter, DateEnd as "End Date", linkedProjects as Projects, file.inlinks

FLATTEN list(filter(file.inlinks, (f) => econtains(type, "Project"))) as linkedProjects

WHERE contains(type, "Quarter")

The result is as follows. There are 2 file.inlinks, one with the value Project the other with the value Goal for the metadata field type.

Any help or guidance would be very much appreciated. Thank you!

To refer to the inlink in question when doing the filter(file.inlinks, (f) => ... ) you need do use f.type, not only type. So try changing to that and see what happens. Your query should then look something like:

```dataview
TABLE WITHOUT ID 
  file.link as Quarter, DateEnd as "End Date", 
  linkedProjects as Projects, file.inlinks

WHERE contains(type, "Quarter")
FLATTEN list(filter(file.inlinks, (f) => econtains(f.type, "Project"))) as linkedProjects
```

I’ve also moved the where quarter type line up above, just to reduce the list of candidates before we filter the inlinks.

1 Like

Oh thank you @holroy! It works like a charm now.

Also thanks for the tip to use Where before Flatten. I imagine as my vault grows this may help with performance.

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