Would love some help to add a sum total to my Dataview query

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

I

I have this table,

TABLE worktime
FROM "Art journal/Years"
WHERE date >= date(today)-dur(1 week)

and wonder if there is a way to calculate the sum total of my worktime, which are just number inputs in front matter in my calendar notes

Things I have tried

Tried copying other bits but can’t seem to find a fit. Sorry, I really struggle understanding coding and don’t really know where to start!

If you want to combine a query with some sum from that query, I would suggest reading and following the stuff in the post below.

If you just want a separate sum you could do something like:

```dataview
TABLE WITHOUT ID  sum(number(rows.worktime)) as Sum
FROM "Art journal/Years"
WHERE date >= date(today)-dur(1 week)
GROUP BY true
```

The idea here is that we group all the entries you want to sum using GROUP BY true (on a query giving you the items you want). This moves all fields into the rows object, so worktime becomes a list found in rows.worktime. We then use sum() to sum the entries, but first we ensure they’re numbers by doing number() on them.

While this latter query do produce the sum, it’s in a table of its own, and there are no easy methods to join those two tables. So for those purposes, it’s better to use one of the approaches in the linked post above.

Screenshot 2024-02-02 at 1.28.05 pm
That’s great, thank you holroy. I’ve saved the link for investigating further and hopefully learning some more in depth - but your solution works fine for me at the moment. Thanks again.

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