Trying to list files that link to the current file (backlinks, but with filters)

I’m using Obsidian to manage my projects.

I have Project notes in their own folder and more loose Area notes with which I tag the projects, in a separate folder.

I want to create a filter to fetch all active project notes that are “tagged” with a specific area

Usually, projects like ‘Write XYZ blog post’ or ‘Finish writing chapter X for book Y’ are tagged areas:: [[Writing]]. I’m currently manually linking to each active project manually in each area note, but I’m sure there’s a smarter way to do it. Ideally, the same snippet of code can be reused in any note based on its name, without me tweaking the filter everytime.

I tried some suggestions from the forum, the closest being specifically Display list of backlinks in note - #6 by efemkay

TABLE WITHOUT ID file.inlink AS "Projects" 
FROM "4. Projects/1. Active" 
WHERE file.name = this.file.name
SORT file.name

However, I’m not able to get it to work… I tried different formulas (I didn’t keep track of all of them tho, sorry about that) and ended up fiddling with this one, but it’s returning nothing (it’s not failing either)

Any idea what I’m doing wrong?

here’s my attempt for you.

  • since you tag the area note within your project note as a link i.e. areas:: [[Writing]] you should use this.file.link instead
  • also, you should try to match areas instead of file.name because of the bullet above. areas is the “key” which you want to find the matching “value” which in this case is [[Writing]]
  • the following dataview code is meant to be inserted inside your areas note. if you place it somewhere else, then you would need to replace this.file.link with explicit value like [[Writing]]
TABLE WITHOUT ID file.inlink AS "Projects"
FROM "4. Projects/1. Active"
WHERE areas = this.file.link
SORT file.name

Thank you for your reply!

Your code seems to be working, BUT I get only one result :thinking:

image

I think that’s because I “tag” files with multiple areas?

I tried the contains method and got it working on everything I have, I think, BUT

image

As you can see, the names are not showing for some reason… any idea why? This is baffling

Here’s my updated query:

TABLE WITHOUT ID file.inlink AS "Projects" 
FROM "4. Projects/1. Active" 
WHERE contains(areas, this.file.link) 
SORT file.name

there’s a typo. it should be file.inlinks with an “s”.

TABLE WITHOUT ID file.inlinks AS "Projects" 
FROM "4. Projects/1. Active" 
WHERE contains(areas, this.file.link) 
SORT file.name
1 Like

Oooh! Now they show. Is it possible that it’s also finding files with no links to it?? I’m trying to test it, but I also get files with no links-- I’m very confused

Edit: providing example

I’m testing this on a page named Writing to find all the notes that link directly to it through that areas:: field. This is what I get, notice the strange formatting and uneven rows

Half of the links there have the areas:: field with [[Writing]] in it

But others, such as this one, have no such field and are not pointing to [[Writing]] anywhere anyway

So, it appears that the solution is to take out the WITHOUT ID file.inlinks AS "Projects" bit. The uneven spacing was caused by the missing key, which was the actual column containing the pages I was looking for

LIST 
FROM "4. Projects/1. Active" 
WHERE contains(areas, this.file.link) 
SORT file.name

Here’s what’s working for me now!

1 Like

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