Dataview expression that read through the link to another link on the second page

This is what I want to accomplish:
For example, I have a page called “Animals” that links out to “Domestic” and “Domestic” links out to “Dog”

Now I have a permanent note “Dogs have intrinsic value”, and on that note, I have a DV Attribute – Category:: [[Dog]]

On my DV query, I’d like to have the following result:

Category Major Category Note
Dog Domestic Dogs have intrinsic value

So the query needs to read through to the “Dog” page (from the note’s Category), to pull up the “Domestic” link.

In reading the DV Docs, I was thinking I saw this and thought it might work:
Link Indexing in Expressions

If your link is a field that you defined in an inline field or in front-matter, like Key:: [[Link]], then you should index into it by just writing Key.value; Using [[Key]].value would look up the page literally called Key, which is probably not what you want!

So I thought if I added Category.value in my query might work. But it didn’t.

So, I figured, I missing the point of the “Linked indexing in Expressions” or what I want to do isn’t possible (or well beyond my capabilities). Thoughts, anyone? Appreciate any input.

The documentation is a little confusing! I think what “value” is supposed to represent there is the name of the DV field in your linked page that you want to access the value of. It might be worthwhile to file an Issue or a Discussion on the dataview GitHub repo pointing out that “value” is a confusing field name in that bit of documentation.

A slightly contrived example: if I had a note “People in my Office” with fields like Desk1:: [[Link to PersonA]] and Desk2:: [[Link to PersonB]] etc. and on every person’s page I had a field Birthday:: MM-DD then I believe I should be able to get myself a table of office birthdays via

TABLE WITHOUT ID
Desk1.Birthday AS "One", 
Desk2.Birthday AS "Two",
...
FROM "People in my Office"

To line that up with the documentation here my "Key"s are the various desks and “value” that I want is the value of the “Birthday” field on the page of the person linked to each desk. You could add another layer of indirection here: let’s say each office has the same number of desks and all your office notes have the same format. Then maybe you have a note called “Hallway” that contains links to the notes “People in my Office” “The Office to the Right” “The Corner Office” “The Office by the Stairs” etc. Then you could modify the query above to get birthdays for the entire hallway by removing “without id” to see which people go with which office. and changing the FROM line to FROM outgoing([[Hallway]]). So for all the offices linked out of “Hallway”, you go through the desk keys to the linked people and index into their Birthday fields. Does that make sense?

Unfortunately I could not quite follow your linking + field naming scheme in your explanation, so hopefully you can translate my example to fit your domain.

Let me know if I can clarify further!

1 Like

SO MUCH CLEARER! Thanks for that. It worked great. Sorry my example was confusing. Your’s was much better. :grin:

1 Like

Yay I am glad that clarified! Would love to see the code for yours if you get it working - this is definitely a topic where I have not seen very many example snippets on the forum and I think the hierarchical classification thing you have will fit many people’s use-cases.

1 Like

Here is my DVQ:

TABLE without ID Link.up As “Main Category”,(Link + “(” + length(rows.file.link) + “)”) AS “Category”,rows.file.link AS “Thought Note”, rows.file.cday AS “Date”
FROM #z/litnote and !“81 ADMIN”
Flatten Link
Group by Link
sort Link.up ASCENDING

And a screen shot of the output:

Only two more things to figure out:

  1. get a bullet point before each “Thought Note”, and
  2. get the date to line up more closely to the associated note name

Thanks!

2 Likes

Note also, I tried to Flatten Link.up, and Group by LInk.up - but that didn’t work at all. But sorting by Link.up did. Go figure. :hugs:

1 Like

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