# Time tracking with dataview and sum of values

**URL:** <https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831>\
**Category:** Basement\
**Tags:** dataview\
**Created:** [May 26, 2021, 2:40pm UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831 "2021-05-26T14:40:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![substa](https://forum.obsidian.md/user_avatar/forum.obsidian.md/substa/32/15359_2.png) [@substa](https://forum.obsidian.md/u/substa)\
**Post date:** [May 26, 2021, 2:40pm UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/1 "2021-05-26T14:40:20Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Rishi](https://forum.obsidian.md/user_avatar/forum.obsidian.md/rishi/32/398_2.png) [@Rishi](https://forum.obsidian.md/u/Rishi)\
**Post date:** [May 26, 2021, 5:36pm UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/2 "2021-05-26T17:36:05Z")

</div>

Have you taken at look at the [Obsidian Tracker](https://github.com/pyrochlore/obsidian-tracker) plugin? It allows you to perform aggregation on values like sum, average and count.

---

<div class="post-metadata">

**Author:** ![substa](https://forum.obsidian.md/user_avatar/forum.obsidian.md/substa/32/15359_2.png) [@substa](https://forum.obsidian.md/u/substa)\
**Post date:** [May 27, 2021, 8:15am UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/3 "2021-05-27T08:15:08Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Rishi](https://forum.obsidian.md/user_avatar/forum.obsidian.md/rishi/32/398_2.png) [@Rishi](https://forum.obsidian.md/u/Rishi)\
**Post date:** [May 27, 2021, 9:58am UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/4 "2021-05-27T09:58:06Z")

</div>

> [@substa](#):
>
> Unfortunately, it seems to works only on daily notes

Where did you get this from? In the documentation, I found [this](https://github.com/pyrochlore/obsidian-tracker#collecting-data),

> 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.

 ![image](https://forum.obsidian.md/uploads/default/original/2X/3/3164cd03a5f2345b4dc9095f4ec0f4588523c957.png)

---

<div class="post-metadata">

**Author:** ![substa](https://forum.obsidian.md/user_avatar/forum.obsidian.md/substa/32/15359_2.png) [@substa](https://forum.obsidian.md/u/substa)\
**Post date:** [May 27, 2021, 12:05pm UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/5 "2021-05-27T12:05:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rishi](https://forum.obsidian.md/user_avatar/forum.obsidian.md/rishi/32/398_2.png) [@Rishi](https://forum.obsidian.md/u/Rishi)\
**Post date:** [May 27, 2021, 1:41pm UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/6 "2021-05-27T13:41:23Z")

</div>

> [@substa](#):
>
> but it expects a date format.

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.

---

<div class="post-metadata">

**Author:** ![pyrochlore](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pyrochlore/32/16082_2.png) [@pyrochlore](https://forum.obsidian.md/u/pyrochlore)\
**Post date:** [June 13, 2021, 12:40pm UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/7 "2021-06-13T12:40:41Z")

</div>

Hi substa and Rishi,

From [Tracker](https://github.com/pyrochlore/obsidian-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,

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

```

---

<div class="post-metadata">

**Author:** ![substa](https://forum.obsidian.md/user_avatar/forum.obsidian.md/substa/32/15359_2.png) [@substa](https://forum.obsidian.md/u/substa)\
**Post date:** [June 14, 2021, 7:54am UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/8 "2021-06-14T07:54:24Z")

</div>

This is a great news 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [June 15, 2021, 7:54am UTC](https://forum.obsidian.md/t/time-tracking-with-dataview-and-sum-of-values/18831/9 "2021-06-15T07:54:36Z")

</div>

Closed on June 15, 2021, 7:54am UTC

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