Sum and Average Word Count in Dataview from a Property

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

Hi all, I log a daily word count in a property/YAML in my daily notes, and I’m trying to set up a Dataview block in my weekly note that will give me the sum and average for the week.

Things I have tried

The property is called “count” and it’s a number. I’m using the FROM and WHERE to point to the daily notes from the week. This setup:

/ ```dataview

TABLE

sum(count) as "Word Count"

FROM #journal/daily 

WHERE contains(week, "2024-OT-33")

generates this view:
image

whereas I would like to see just a number, the total sum of the “count” field for the week’s notes.

An average would be a nice-to-have, and I imagine is pretty easy to do once the sum is working properly.

Thanks for reading and appreciate any help!

All the aggregate function mainly comes to life after doing a GROUP BY, so in your case I’d try with something like:

```dataview
TABLE sum(rows.count) as "Word Count"
FROM #journal/daily
WHERE contains(week, "2024-0T-33")
GROUP BY true
```

Note that when you do GROUP BY true it’ll group all lines from this query, and also that fields are now moved into the rows object. So if you had a count property in each file, after the grouping you can now get to this list of values from rows.count.

A similar query which would allow you to see the result for multiple weeks, could possibly look like:

```dataview
TABLE sum(rows.count) as "Word Count"
FROM #journal/daily
GROUP BY week
```

This assumes there is only a unique value in the week property.