First of all file.day
will get its value from either a properly formatted date within the file title, or from the field date
within the YAML/frontmatter/properties. With properly formatted date I’m referring to the yyyy-MM-dd
format, as see date format.
So with a file name of “2023.12.24” and no date
property, you’ll not get a value into file.day
. You can however do something like date(file.name, "yyyy.MM.dd")
to interpret that file name as a date. It would be nicer however to use a proper date in the date
field, so that you don’t have to convert the file name all the time.
Regarding the second half of your request to get those values you’ll need to calculate the number of tasks in general and the number of completed tasks, before grouping together the results and presenting them.
Here is an example query to get you started, where it’s assuming that the file.day
has been properly set. Since tasks can have all kind of status characters, besides the ordinary “
” and “x
”, I’m explicitly counting just those tasks. If you want to include cancelled tasks, or partially started tasks, or something else like that you’ll need to extend the filter functions appropriately.
```dataview
TABLE
sum(rows.taskCount), sum(rows.completedCount)
WHERE file.tasks AND file.day
FLATTEN length(filter(file.tasks, (t) => t.status = " " OR t.status = "x")) as taskCount
FLATTEN length(filter(file.tasks, (t) => t.status = "x" )) as completedCount
WHERE taskCount > 0
GROUP BY dateformat(file.day, "yyyy-MM")
SORT key
```
If you want the first column to be localised, you could exchange the first line in that query with something like:
TABLE WITHOUT ID dateformat(rows[0].file.day, "LLLL yyyy"),
Hope this helps, and gets you going. It’s actually kind of a complex query as it does a lot of data manipulation to get the result you’re asking for.