Help with inlinks and Properties

Dear all,

I was trying to do a query returning a table with all inlinks coming from a a specific property.

I would clarify using a basic example: I have two kind of files scenes and characters.

Scenes contains two properties that are links to Characters: “Actual” and “Referred”.

The first one are actually involved into the scene, the second ones are instead referred in some way (talked about, remembered as they were dead or lost, etc…)

Now, I’m able to do a table for each characters filtering away the “referred” links but I’m failing to replicate the query to obtain a panel including all characters and they corresponding scenes.

What I’m trying to do

The simple query that is working for a character is the following

TABLE WITHOUT ID as Scene, characters AS "All characters", referred-characters as "Referred Characters", location as Location
FROM [[]]
WHERE contains(characters,[[]])

Things I have tried

After two days, I was not able to find a reference to understand how to replicate it in a table that contains all files into the foldere Characters.

The simple query is

TABLE length(file.inlinks) as number_Inlink, file.inlinks as Inlinks
WHERE contains(file.folder, this.file.folder) 

But I don’t know how to put away from it the links coming from “referred-characters” to show only the list of characters and the scenes in which they are really involved.

As you could understand, I’m very at beginning with Dataview so probably the answer is very trivial…

Thank you in advance for your help.

Could you show some basic examples on how you define the properties of “Actual” and “Referred”. And in which note do you want to list this information? In the evergreen, at the character note? Elsewhere?

Hi holroy, for sure.

My scene frontmatter is quite simple

- "[[Personaggio1]]"
Referred Characters:
- "[[Personaggio2]]"
Luogo: "[[Luogo1]]"

In the example there is just a characters for each list but there could be more.

What I would like to obtain a table like the following one in a file that is not a scene/neither a characters file. I’m not sure but I would like to have it as a general panel to have a coherent view of the whole content. At same time, I could put in each character note a list of the scene involving this specific character (but this part seems to work, at least in the very simple way I was starting from).

As last information, Location is not needed but it is a nice to have, it could be sufficient to have just the pair character-scene.

Characters Scene Location
Char 1 Scene 1 Location 1
Scene 2 Location 2
Char 2 Scene 1 Location 1

Thank you again for your time.

The following is untested, but it could work I guess… :stuck_out_tongue:

TABLE as "Scene(s)", rows.Luogo as "Location(s)"
WHERE Characters
FLATTEN Characters as Character
GROUP BY Character

This assumes that your scenes are the only one defining Characters. If that’s not the case, you need to add something to the WHERE statement to limit the query to only look at your notes describing Scenes.

It works! I really need to better understand DQL. Because, I didn’t know the “rows” clause and I don’t understand why “GROUP BY” is so relevant for the query to work.

Could you suggest me a bible for it? A website or something else that goes deeper with respect to the basic official documentation?

Anyway the main problem is solved and I have to study a lot what is possible with Dataview.

Again, thanks a lot!

The quick and dirty of what happens when you do GROUP BY:

  • Every unique result of the GROUP BY expression is stored into key and used as the TABLE’s first column (replacing the or what not)
  • Every other fields, like a or b are gathered up (or grouped :smiley: ) into lists within the rows objects for each unique key. So previously it was just a, but now it’s a list found at rows.a for that particular key
  • Bonus tip: If you do GROUP BY ... as "Something" you can rename the first column to your liking, i.e. “Something”. It’ll also allow you to access the value of the expression as “Something”
  • Now that we’ve got grouped results, we’re also able to do stuff like min(), max(), sum(), average() and some more on the lists. So get the first/lowest value of the date property, you could do min(, and to count how many is in that particular group, just do length(rows)

And I don’t know any good resources besides coupling together the official documentation as best as you can, and ask for guidance on the rest! :smiley:

Thanks! I cannot ask for more. :smiley:

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