I have a database that contains stories written by authors. Each note has a bunch of YAML tags that look like this:
---
author: "Arthur"
words: 3579
date: 2024-12-15
type: "long story"
---
---
author: "Arthur"
words: 231
date: 2024-12-17
type: "short story"
---
---
author: "Bob"
words: 152
date: 2024-12-16
type: "short story"
---
What I’m trying to do
My goal is to use Dataview to have a monthly summary of activity of each of the authors. My ideal table would look like this:
Author | Words | Long stories | Short stories |
---|---|---|---|
Arthur | 3810 | 1 | 1 |
Bob | 152 | 0 | 1 |
Things I have tried
I didn’t have a problem summing the number of words and aggregating them by author, but after I added the column “Long stories” the table stopped counting all the words that were written by a particular author, only for the long stories. And I can’t add any more columns. Is there a way to make Dataview calculate all the words written and then simply give a number of particular types of stories written by a certain author?
```dataview
TABLE WITHOUT ID
Author,
sum(rows.words) as "Words",
length(rows.Type) as "Long stories" WHERE Typ = "long story"
WHERE date >= date("2024-12-01") and date <= date("2024-12-31")
WHERE author != null
GROUP BY author
SORT author ASC