Time tracking with dataview and sum of values

Hello,

I’m trying to recreate my current workflow for Task management (todoist) + Time Tracking (toggl) in obsidian.

I created a template for tasks like this:

---
tag: tasks
---
# Test task
Project:: [[projectname]]
Client:: [[clientname]]
Status:: Active
Label:: 
Priority::
Due Date::
Completed:: [[2021-05-26]]
Duration:: 1h

Notes:: 

And then I can list tasks with this code:

```dataview
table Completed, Priority, Project
from #tasks 
where project = [[projectname]] 
```

With dataview I’m able to create different tables for available, upcoming, completed tasks, etc etc, and I’m quite satisfied with the result.

However, I can not get a feature essential for time tracking: the sum of hours.
Example:

|File     |Completed |Duration|Project       |
|---------|----------|--------|--------------|
|Test task|2021-05-22|1 hours |projectname   |
|Testtask2|2021-05-22|12 hours|projectname   |

Total: 13 hours

How can I obtain this value?
Is it possible to obtain the sum of the column “Duration” in dataview?
Is there an alternative approach to achieving this?

Thank you and have a nice day :slight_smile:

2 Likes

Have you taken at look at the Obsidian Tracker plugin? It allows you to perform aggregation on values like sum, average and count.

1 Like

Hi Rishi,
thank you for making me discover this interesting plugin. I’m sure I’ll use it in many contexts!

Unfortunately, it seems to works only on daily notes, so I think it’s not able to solve my current problem. (Each task has its own note, and dataview tables are rendered on project notes)

Where did you get this from? In the documentation, I found this,

Providing parameters 'searchType ’ and 'searchTarget ’ is the minimum requirement for a successful data collection. The value of the key 'searchType ’ can be 'tag ', 'frontmatter ', 'wiki ', 'dvField ', 'table ', or 'text ’ and the cooresponding 'searchTarget ’ should be provided according to the specified type.

As you can see from the table too, it can search the entire vault using tags or front matter or any other fields even arbitrary text. Perhaps, download the examples and test a bit to explore it more? Good luck!

Edit: My bad, the docs also mention helps you do tracking in daily notes and represent the data comprehensively. in the very first line which I missed. I haven’t used the plugin much yet but I had seen the examples and some of them had folder: diary while others had folder: / which makes me think it should work with any folder. I should do more exploring perhaps.

Edit2: This setting for the plugin makes it clear that we can use any folder and it’s probably only the doc wording that’s slightly confusing.

You can use any folder, but it expects a date format.
I can’t use date format as task name, because I have many tasks in the same day.

1 Like

Aha! I did remember having issues with it not picking up some of my fields but I didn’t check in detail. Thanks for this piece of info.

1 Like

Hi substa and Rishi,

From Tracker version 1.6,
we are not limited to work on daily notes (files named by dates) anymore.
Any collected dates information can be used as x values.
And with the output type ‘summary’, we can use template variable {{sum}} to get the summation of all duration distributed in notes.

For example,

searchType: dvField
searchTarget: Completed, Duration
folder: todo
xDataset: 0
summary:
    template: 'Total hours spent: {{sum}} hours'
4 Likes

This is a great news :slight_smile:

1 Like

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