What I’m trying to do
I have a dataview table that display the author, literature note, and the journal. The issue is that this list is getting quite long so I’m trying to divide the table by the first letter of the author’s name, like a glossary.
I have literature notes, in which there is a field “authors” and the values are the internal links to notes where the title of the note is the author.
For example, I have a note called [[Eslami.Jafari.ea2021]]. Inside, I have in-line fields that look like,
authors:: [[Eslami, Mohammad H.]], [[Jafari, Hamid]], [[Achtenhagen, Leona]], [[Carlbäck, John]], [[Wong, Alex]]
What I’d like to achieve are 26 tables, one for each alphabet.
Things I have tried
I’ve managed to go from the image above to the image below by using the command
where substring(Authors.file.name,0,1) = "A"
.
The first issue is that most of my authors’ name file are not yet created so when I used this command where substring(Authors.file.name,0,1) = "A"
the table only returns authors files that have already been created. I’ve tried using Authors.link
but it didn’t work
table rows.file.link as "Literature Note", rows.publisher as "Journal"
from "30 zotero import"
flatten authors
group by authors as Authors where substring(Authors.file.name,0,1) = "A"
sort rows.authors ASC
limit 600
The second issue is, is there a workaround so that I don’t have to create 26 tables? The closest topic that I found on the forum was this topic, but I’m not sure how to modify it to suit my needs.
Below is my failed attempt at dataviewjs (I have zero knowledge on javascript).
let groups = dv.pages()
.where(p => p.file.folder = "30 zotero import")
.sort(p => p.file.name)
.groupBy(p => p.file.name.substring(0,1).toUpperCase())
for (let group of groups) {
dv.header(4, group.key);
dv.table(
["Authors", "Literature Note", "Journal"],
.sort(k => k.file.name)
.map(k => k.file.))
}