Dataview: Sum/Total all notes

Friends i have notes with metadata like this:
begin: …
End: …

  • What im trying to do with dataview is to sum all begins and ends with all my notes, to have a better overview

  • but im only getting the total of begin and end of each note with this code:

TABLE  sum(begin) as test, sum(end) as test2
FROM "" 

tried group by but also didnt achieve

Any tips ?

Thanks in advance !

Could you provide a little more information? Such as:

  1. A few examples of what’s in your “begin” and “end” fields, and
  2. What you want the output to look like?

sure

Example note 1:
begin: 2
end: 5

Example note 2:
begin: 7
end: 20

Example note 3:
begin: 2
end: 10

  • would like to dataview take all my notes and sum all the “begins” and “ends”, so the output in this example would be :
    • total begins: 11
    • total ends: 35

One example for “total begin” using DQL:

LIST "total begins: " + sum(rows.begin)
WHERE begin
GROUP BY true
1 Like

Haha, @mnvwvnm beat me to it! :smiley:

I’ll add a little more context to his good answer:

The sum() function works on an array of values. One way to get a sum like this is to put all of your pages into a group. Here’s a query that does that:

```dataview
TABLE WITHOUT ID
	sum(rows.begin) as BeginTotal, 
	sum(rows.end) as EndTotal 
FROM "Test"
WHERE begin AND end
GROUP BY ""
```

Here’s what it looks like in action:

Let’s break down the query:

  • TABLE WITHOUT ID - don’t show the File column since we don’t need it.
  • sum(rows.begin) as BeginTotal, - Sum the “begin” fields into the BeginTotal field.
  • sum(rows.end) as EndTotal - Sum the “end” fields into the EndTotal field.
  • FROM “Test” - Only look in the folder called “Test” (this is specific to my vault. :slight_smile: ).
  • WHERE begin AND end - Only look at pages that have both a begin and end field (again, maybe specific to my vault).
  • GROUP BY “” - Put all the pages into a single group. I use an empty string here, @mnvwvnm used true – either works.

I hope this helps! Happy Dataviewing!

Craig

2 Likes

thanks bro, you guys are the dataview kings

thanks bro, you guys are the dataview kings, happy holidays to you all

1 Like

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