Sum of Duration across all instances

You’ve got some non-duration values in there, which could cause issues when adding up the total, so here’s a query to list those:

```dataview
TABLE RDR2
From "Permanent/Diary"
Where RDR2
  AND typeof(RDR2) != "duration"
```

Hopefully this just list out those few text variants in there, but I’m a little “worried” about that multi-valued variant in there.

The main query, untested but hopefully working, is as follows:

```dataview 
TABLE WITHOUT ID 
  sum( filter(flat(rows.RDR2), (r) => typeof(r) = "duration" )) as "Total playing time"
FROM "Permanent/Diary"
WHERE RDR2
GROUP BY true
```

The trick here is to first select only the files having the field, and then group everything into rows.RDR2, before treating this multi-level list using flat(). flat() flattens the list to one level, allowing us to filter out only the values which are durations, which we then sum to get the total playing time.

2 Likes