Count / sum habits

I want to count the amount of exercise I do per week.
I don’t want a table with the amount of exercise I did every day with one row per day. I just want the total.

In my daily note, in the front matter, I have something like this.

exercise: 30

Can I do this with dataview?

I think that’s possible, but with dataviewJS.

I only use simple dataview queries. But I found this in Obsidian discord channel:

```dataviewjs
dv.paragraph(dv.pages()
	.exercise.array().reduce((acc, val) => acc + val, 0)) 

(“exercise” is the name of your placeholder)

The problem: this gives you the total for all “exercise” fields in your vault. You need to restrict your source to a file name or a folder name (or other conditions, like dates). But this depends in how you create your weekly note (or a weekly folder).

That could work, I’ll try it. Thanks!

Hi there. Did this work for you?. I want to also sum values through dataview.

1 Like

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