How to use dataview to list all notes links/are linked to a note in folder A?

Hello, I’m new to Obsidian and I find it’s really powerful.

Now I want to list all the notes in field B that are related to field A.

For example, there are three folders in Obsidian: A, B and C, each containing notes.
Now, I create a new note in C, and I want to filter the notes with the dataview plugin.The filtering rule is:
If a note is in folder B, and the note links (outgoing link) to note in folder A, it will be filtered;
If a note is in folder B, and the note is linked (backlink) to note in folder A, it will also be filtered.

If you could provide some solutions, that would be so great. Thank you so much.

For test purposes, use this tables (to see and check the results: paths, files, etc)

```dataview
TABLE file.outlinks, file.outlinks.file.folder, file.inlinks, file.inlinks.file.folder
FROM "path-to-your-folder B"
WHERE endswith(file.outlinks.file.folder, "folder A") OR endswith(file.inlinks.file.folder, "folder A")
SORT file.name ASC
```

If only a list:

```dataview
LIST
FROM "path-to-your-folder B"
WHERE endswith(file.outlinks.file.folder, "folder A") OR endswith(file.inlinks.file.folder, "folder A")
SORT file.name ASC
```
1 Like

Hello, I test this approach, and this is the folder:

test.zip (2.1 KB)

In folder B, only B01, B02, B03, B04 have links with notes in folder A, so they should be filtered. Notes have links with other notes shouldn’t be displayed. So,

  1. B05 shouldn’t be filtered, and B01, B04 should be filtered.
  2. The boxes indicated by the arrow in the following figure should not be displayed.

Well. This is not a resolution à la carte!

I started to give you a way without all information! A start solution only thinking in links between both folders.

You return with a more complex inter-links (good, because reveal some issues with a command I never use - endswith - but others I don’t understand because they work on my side) but with a new request to another filter (a output/view filter), i.e, a filter to hide something that is correct: real out/in links from/to notes in folder B.
It’s a new request in two ways: 1) because you never ask for a table (you mention a list) and 2) you want to hide them.

I’m a normal user (no coder or similar), a newbie guy that help others with my own limitations.

In help, I’d like to see some effort from the other side. You start with your request but I never see any attempted dataview query. How I know you read the plugin documentation?

Don’t understand me wrong, because I know that in some cases we have some limitations (as in my case the language, because english isn’t my native language)… but I spend a lot of time given solutions to some people that are interested only in solve one problem (his own) without understand the minimum of the tool! To someone that try to explain some steps this is frustrating…

Well. Forward… I think it’s necessary to replace endswith() by contains() and add extra filters to fields in table columns (but I don’t know if you want all that columns… I added them only for test purposes…). Try this:

```dataview
TABLE filter(file.outlinks, (o) => contains(o.file.folder, "test/A")) AS Outlinks, filter(file.outlinks.file.folder, (f) => contains(f, "test/A")) AS "Outlinks Folder", filter(file.inlinks, (i) => contains(i.file.folder, "test/A")) AS Inlinks, filter(file.inlinks.file.folder, (g) => contains(g, "test/A")) AS "Inlinks Folder"
FROM "test/B" 
WHERE contains(file.outlinks.file.folder, "test/A") OR contains(file.inlinks.file.folder, "test/A") 
SORT file.name ASC
```
2 Likes

English is also not my native language🥲
My English is not good, so it’s very hard for me to read the plugin documentation…
I tried to read some introductions about dataview written by my native language, and I can only write something like this:

​```dataview
list 
from "600 Notes/610 concept" and ([[Obsidian]] or outgoing([[Obsidian]]))​
\```

I never realize there are “endswith” and “contains” function in dataview :astonished: I will learn these functions.

I think your solution works correctly. Thank you so much for your help. If I need list, I will use this:

```dataview
LIST
FROM "test/B" WHERE contains(file.outlinks.file.folder, "test/A") OR contains(file.inlinks.file.folder, "test/A") 
SORT file.name ASC
\```
2 Likes

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