Hello, I’m new to this forum and Dataviews, although I’ve been using Obsidian for several years. Among other things, I am tracking my activities in a daily journal, which looks like this:
- [ ] (activity:: teaching ) (project:: [[240900-idem-4101-master-fc1]]) (timespent:: 4h)
- Kick-off meeting
- Introduction Tutor
- [ ] (activity:: writing ) (project:: [[240805-chi-2025]]) (timespent:: 2h)
- review background section
- [ ] (activity:: writing ) (project:: [[240827-nwo-xs]]) (timespent:: 1h)
- Rewrite intro
Discovering Dataviews, I recently added the double columns for activities, projects and timespent, hoping to generate summaries. I have been able to create a table capturing all my tasks from the daily journal notes.
TABLE item.activity AS Activity, sum(default(item.timespent.hours, 0)) AS "Time Spent", item.children.text as Comments
FROM "journals"
FLATTEN file.lists as item WHERE !item.parent
WHERE item.activity
What I’m trying to do
My goal in this process is to be able to see how much time I spend on each activity (e.g., teaching, writing), which I thought I could achieve with a GROUP BY and a SUM function (this is what I would do with my SQL background). With the code below, I get the groups (two for the example above). However, I don’t get a sum value in the column ‘Time Spent’ (only a 0). With the example above, I expect to get 2 lines (for teaching and writing), respectively indicating 4 and 3, the sum of the timespent values.
Things I have tried
This is the code I’ve played with so far:
TABLE sum(default(item.timespent.hours, 0)) AS "Time Spent"
FROM "journals"
FLATTEN file.lists as item WHERE !item.parent
WHERE item.activity
GROUP BY item.activity AS Activity
I want the default value 0 because, in some cases, I don’t put a timespent value. When I remove this part I get only dashes.