Hi all,
Thanks for pinging me. This is an interesting problem! I think the issue is that we have a calculated field (workhours) that needs to be calculated per file before we can aggregate it up to the week level. Here’s the query I used to do the calculation:
```dataview
TABLE
sum(map(rows, (item) =>
date("2022-01-01T" + item.clock-out) -
date("2022-01-01T" + item.clock-in)))
as "workhours"
FROM "Scratch"
WHERE file.day
GROUP BY dateformat(file.day, "WW | yyyy") as "calendarweek"
SORT calendarweek desc
```
Before we can sum hours for the week, we must first use the map() function to iterate over each file and calculate the work hours for the day. That returns a list of durations, which we then use the sum() function to add together into a single field, which we name “workhours”.
I sort by week descending in this example, since that seems to be what you intended in your query.
(The FROM and WHERE clauses are different than yours, so as to just select the files from my particular vault.)
Finally, here’s a working example from my vault:
I hope this helps! Please let us know if it works for you.