Sum of hours in Dataview

Try the following queries, and see if they do something like what you’re looking for:

## Base query
```dataview
TABLE WITHOUT ID item.Day, item.children.text, cTime, cTask
FROM "Z - Playground/Note"
FLATTEN file.lists as item
FLATTEN filter(item.children, (c) => c.Task)[0].Task as cTask
FLATTEN filter(item.children, (c) => c.Time)[0].Time as cTime
WHERE item.Day
```

## Grouped by month, and summed
```dataview
TABLE sum(rows.cTime) as "Time", rows.cTask as "Tasks"
FROM "Z - Playground/Note"
FLATTEN file.lists as item
FLATTEN filter(item.children, (c) => c.Time)[0].Time as cTime
FLATTEN filter(item.children, (c) => c.Task)[0].Task as cTask
WHERE item.Day
GROUP BY dateformat(item.Day, "yyyy-MM") as Month
```

The trick to both of these queries is that we’re picking out only the list items actually having a Day inline field, and then we look at the children of that item to lift the Time and Task from it. In the second query we then group on the Day field, and since we group then we need to do the sum on the rows.cTime field.

1 Like