I have a note with some checkboxes organized like this :
Note 1
a1
b1
c1
Note 2
a2
b2
c2
I want to count checked or unchecked checkboxes.
For that i use (for example for the unchecked boxes) : length(this.file.task) - length(filter(this.file.tasks, (t) => t.completed)
Or ```dataview TABLE length(filter(file.tasks, (t) => !t.checked)) AS "Not done", length(filter(file.tasks, (t) => !t.checked)) + length(filter(file.tasks, (t) => t.checked)) AS "Done" FROM "Note" ```
But i would like to display separently “Note1” and “Note2” or either “Note1” or “Note2”.
I mean, if i have 2 unchecked checkboxes in Note1 and 1 in Note2, it will display “3 unchecked boxes”, but I don’t know how to consider only “note1” for example.
Hi,
Thank you for your reply, but maybe i didn’t understand but your code (like mine) consider “note1” and “note2” together.
In my example, “note1” and “note2” are to different part in the same file. Actually, i would like to keep “note1” and “note2” in the same file but count only for the part called “note1” for example.
Sorry otherwise maybe i do mistake and i don’t know dedfine tasks or something lke this.
So in essence you want to calculate stuff from a given note based on sections (and not on separate notes). That explains a few things. Try the following query then and see if that returns what you want:
```dataview
TABLE length(rows) as Count, completedCount, uncheckedCount
WHERE file = this.file
FLATTEN file.tasks as task
GROUP BY meta(task.section).subpath as Section
FLATTEN length(filter(rows, (r) => r.task.completed)) as completedCount
FLATTEn length(filter(rows, (r) => r.task.status = " ")) as uncheckedCount
```