Im trying to create a dataview table to show the number of tasks created and the number of task completed by date for a 7 day period.
Things I have tried
I was able to figure out how to get the information in 2 different tables but I can seem to get it combined into 1 table. Any help would be much appreciated. Im pretty new to Obsidian and a complete newb when it comes to dataview.
TABLE WITHOUT ID
key as Date,
length(filter(rows.tasks, (c) => c.created)) AS Created
FLATTEN file.tasks as tasks
WHERE tasks.created >= date(2024-09-30) and tasks.created <= date(2024-10-04)
GROUP BY tasks.created
TABLE WITHOUT ID
key as Date,
length(filter(rows.tasks, (c) => c.completion)) AS Completed
FLATTEN file.tasks as tasks
WHERE tasks.completion >= date(2024-09-30) and tasks.completion <= date(2024-10-04)
GROUP BY tasks.completion
I reckon you should be able to combine the two in order to get your wanted results. That is if you do GROUP BY [tasks.created, tasks.completion] you should retain the needed information, and from there calculate the respective values.
You’d possibly need to do a secondary grouping on a combined date, but it should be doable, I think…
Another alternative would be to use dataviewjs, execute the two queries separately, and then combine the results afterwards.
TABLE WITHOUT ID
key as Date,
length(filter(rows.tasks, (c) => c.created)) AS Created,
length(filter(rows.tasks, (r) => r.completion)) AS Completed
FLATTEN file.tasks as tasks
WHERE tasks.created >= date(2024-09-30) and tasks.created <= date(2024-10-04)
GROUP BY [tasks.created, tasks.completion]
This adds the date twice to each row and the values are off.
Example: 10/01 should have 7 created and 6 completed.