Use Links as Inline Key Field in Dataview to query content from Daily Notes?

Things I have tried

I have looked up the help files for Dataview and also the documentation. I do not know Javascript, so don’t know if dataviewjs can solve this. Would appreciate any help on this.

What I’m trying to do

I want to use links as Keys for Inline fields just like I can use tags as Keys for inline fields. The question I have is how do I use Links for the same. For Example…

I write most of my notes on the Daily Notes pages (DNPs). Here I may have a conversation with PersonA and another with PersonB and I capture the notes as below on Today’s DNP.
[[PersonA]] Spoke with Person A and we discussed blablabla…
[[PersonB]] Spoke with Person B and he said BLABLABLA
I would have other conversations with these persons on previous Daily notes pages (DNPs) as well

What I want to do is capture the conversations as below, as InLine Dataview fields in my DNPs…
[[PersonA]]:: Spoke with Person A and we discussed blablabla…
[[PersonB]]:: Spoke with Person B and he said BLABLABLA
and query all conversations I had with Person A across the different DNPs, as below

TABLE Person A
FROM "journals" and [[Person A]]

This creates a table that has all the DNPs that contain [[Person A]], but the content after that e.g the notes about the conversation I had, doesn’t show under ‘PersonA’ column

However, instead of links, if I use tags as in…
#PersonA:: Spoke with Person A and we discussed blablabla…
#PersonB:: Spoke with Person B and he said BLABLABLA
and query all conversations I had with Person A as below

TABLE PersonA
FROM #PersonA 

I get a proper table with the content

Any ideas, what I am missing or is there another way to do this with Links?

Orginal post by @Boksir

The syntax of [[link]]:: value is not recognised by dataview as a field, so you’ll need to change your syntax to something else. The tricky part is that it would be nice to have a field having both the link, and the text, but you can’t do compound object inline currently.

talk:: [[John Doe]] Talked to John Doe regarding something strange
talk:: Yet another talk with [[John Doe]], but not with [[Log ALIAS stuff|John]]
talk:: Talked to [[Jane Smith]] about [[John Doe]]
talk:: Talked to [[John Doe|johnny boy]] about nicknames

If you use the above syntax, you could on the PersonA page do:

```dataview
TABLE t
WHERE talk
FLATTEN talk as t
WHERE contains(t, string("[[PersonA]]"))
```

And it would catch all of the above examples except the last one, since we’re doing a pure string check agains [[PersonA]]. You could potentially simplify the test to PersonA, but that could also lead to false positives. And it’s debatable whether the third case is one which should be presented on PersonA’s page, since you didn’t talk to them, just about them.

A similar approach, where we rely on the person link in a slight better way in my opinion, would be to switch to either tasks or lists to contain the information like in the following example:

- [M] Talked to [[John Doe]] regarding something strange
- [M] Yet another talk with [[John Doe]], but not with [[Log ALIAS stuff|John]]
- [M] Talked to [[Jane Smith]] about [[John Doe]]
- [M] Talked to [[John Doe|johnny boy]] about nicknames

With a little CSS this could be displayed as:
image

And if say that we always link to the person as the first link, we could this query on PersonA’s page:

```dataview
TASK
FROM [[]]
WHERE outlinks[0] = [[]]
```

If you would like to include all references to PersonA, you could use WHERE contains(t.outlinks, [[]]) instead. Either of these variants would also handle aliases or various different ways of linking to it, i.e. with full path and so on. As it stands the query would return:

And since this is a pure task query, you could click on the task text and it would link back to where it was defined/written originally.

1 Like

Hi Holroy,
Thank you so much for the detailed response. But i wish I could use the key as link, and every time when I type the key value, so I will be able to see the linked note. Such as I track Gratitude every day in my daily notes.

[[Gratitude]]:: I am grateful for everything…Balabala…

After a few weeks, i want to see all the things i have written about gratitude without searching the “Gratitude” note, but go directly from daily note.

I saw someone use roadmap language to query such thing, unfortunately that post has been expired.

Again, much appreciated your time and help!

Then you’ll need to write your own plugin, or get dataview to extend their field detection, or you need to start scanning all files looking for this pattern…

1 Like