Using Dataview to find all files which inform a topic file

Things I have tried

I have searched the forum and the Dataview website for a solution.

I have tried these codes

table  file.link.informs 
from ""
where informs
table  file.link.informs 
from ""
where informs
group by informs
table file.inlinks
from #concept or #themes 

What I’m trying to do

In my vault I have concept files, tagged #concept, and theme files, tagged #themes. I also have many literature files which are relevant to these concepts and themes. These literature files are annotated with inline field informs:: [[name of concept]] or informs:: [[name of theme]].

I would like Dataview to show me in a tabular format all the literature files which link to each concept or theme. For e.g.

|File                  | Informed by               |
---------------------------------------
|[[Motivation]] | [[link to literature 1]] |
|                        | [[link to literature 2]]|
---------------------------------------
|[[Media]]        | [[link to literature ]]   |
---------------------------------------

I hope the above clarifies what I am trying to achieve.

Thanks.

I have also used this

dv.table(["concept", "Informed by"],
dv.pages("").where(b => b.informs)
	.map(b => [b.informs,b.file.link]))

The problem with this is that I can’t see literature notes clustered around a concept.

Hi.
To start, one question: in your table, you want in the first column all files (the source) that have the tags #concept or “themes”, right?
If so, the first step is the definition of the source (the “core” files).
Then, you want all files that link to these notes (backlinks / inlinks) or only the the backlinks which have the field informs with a link to the concept/themes notes?

For test purposes, start here:

TABLE file.inlinks AS Backlinks, file.inlinks.inform AS Inform
FROM #concept OR #themes

If you have backlinks from other notes (not only from the notes with the inform field, then it’s necessary to apply other filters… like WHERE contains(file.inlinks.inform, file.link).
Maybe you need other filter, but start here.

1 Like

Hi,

Thanks for the reply. I tried your code. Because I only wanted inlinks which contain the field inform:: , I used the filter

But received 0 results :disappointed:
image

what you get without the where filter?

Sorry,

I made a typing error :sweat_smile:. I should have types informs instead of inform.

TABLE file.inlinks AS "Backlinks" 
FROM #concept OR #themes 
WHERE contains(file.inlinks.informs, file.link)

Your code works fine.

Thanks a lot

:+1:
Great.

1 Like

Hi,

I just want to mention a small technicality. The filter, where contains(file.inlinks.informs,file.links), filters only the file.link. But it doesn’t filter the file.inlinks. Therefore, the inlinks displayed against the file.links contain both inlinks where informs exist and inlinks where it doesn’t.

That’s why I said what I said in my first post!

So, you have a “File A” that contains an inlink (backlink “Back 1”) with the field informs linked to “File A”. This is the first condition.
But “File A” has more inlinks… and you want to see only “Back 1”.
To do that we have two options… but maybe this is the most direct: filtering directly in column declaration. Something like:

TABLE filter(file.inlinks.informs, (i) => contains(i, file.link)) AS "Backlinks" 
FROM #concept OR #themes 
WHERE contains(file.inlinks.informs, file.link)

Try it and tell me if it works (technically speaking). :slight_smile:

The filter just returns file.link not the filtered file.inlink required. Or perhaps it is just returning file.inlink.inform which is also the same as file.link.

:thinking:

I hope I am making sense :smile:

:man_facepalming:
Of course… (without tests I mess up…). The filter order is switched:

TABLE filter(file.inlinks, (i) => contains(i.informs, file.link)) AS "Backlinks" 
FROM #concept OR #themes 
WHERE contains(file.inlinks.informs, file.link)

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