pfrize
September 9, 2024, 10:06pm
1
What I’m trying to do
As many, I use a combination of folders, tags and links.
For tyding up purposes, I have designed queries that produce statistics:
table of folders and the number of notes in each folder:
TABLE WITHOUT ID Dossier, length(rows.file.link) AS Nombre
GROUP BY file.folder as Dossier
table of tags and the number of notes for each tag:
TABLE WITHOUT ID tag, length(rows.file.name) AS Etiquette
FLATTEN file.tags AS tag
GROUP BY tag
SORT tag ASC
But I do not know how to produce, for a given note, a table of child notes and the number of their own child notes - something like:
TABLE Child_of_TopNote, Count_of_grand_children
FROM [[TopNote]] and !outgoing([[TopNote]])
Is this possible with dataview, or does this require dataviewjs? - in which case any code snippet would be most helpful.
This should be doable in plain Dataview. (I’m going to adopt the convention of naming the starting node/note “root”.)
TABLE length(file.outlinks) as Num_Grandchildren
FROM outgoing([[root]])
outgoing()
produces a record for each outlink (child link) of the specified note. Each individual record is represented by file
in the query. So, file.outlinks
holds the children of each of these child notes (the grandchildren of the original, or “root”).
holroy
September 10, 2024, 11:53pm
3
What do you define as a child note? Any link going out of that note, aka file.outlinks
?
And what about grand children? Just another level of outlinks
?
Are you looking for something like:
```dataview
TABLE
length(file.outlinks) as "child count",
length(file.outlinks.outlinks) as "grand children count"
```
pfrize
September 13, 2024, 4:51pm
4
I cannot make any of these solutions work. But I may have not been clear enough. So here is the content of my test top note named “Inventory”:
A simple query of the Inventory’s child notes:
LIST
FROM [[]]
SORT file.name asc
The two child notes including a query on their own child notes:
My objective: to produce this table in this Inventory note (without reference to the folder):
Category
Count
Appliances
1
Furniture
2
Solution from social-flattery-ton:
TABLE length(file.outlinks.outlinks) as Num_Grandchildren
FROM "TEST_COUNT" AND outgoing([[]])
Solution from holroy:
TABLE length(file.outlinks) as "child count", length(file.outlinks.outlinks) as "grand children count"
FROM "TEST_COUNT" AND outgoing([[]])
I hope this will be less confusing than my first post!
system
Closed
December 12, 2024, 4:51pm
5
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.