DEV Community

Aleksandar Sabo
Aleksandar Sabo

Posted on • Originally published at softwarewitchcraft.com

How to Count and Track Checkboxes in Obsidian with Dataview

As a developer juggling multiple projects and responsibilities, I rely on Obsidian for personal life management (PLM). One of the ways I keep track of tasks is through simple checklists in various notes. Over time, I found that manually checking each note to see my progress was inefficient. I wanted a way to display an overview of my progress—specifically, the number of completed tasks out of the total—directly on my dashboard.

Obsidian’s Dataview plugin provided the perfect solution for this.

The Goal

My objective was to automatically count checkboxes from a specific file and show a summary like this:

3 / 12 | My Todos
Enter fullscreen mode Exit fullscreen mode

This way, I could quickly assess my progress without opening multiple files. The count should dynamically update whenever tasks are checked or added.

The Solution

Using Dataview inline queries, I wrote the following snippet and placed it in my dashboard note:

`$= dv.page(dv.current().file.folder + "/todo/My Todos").file.tasks?.filter(t => t.completed).length || 0` / `$= dv.page(dv.current().file.folder + "/todo/My Todos").file.tasks?.length || 0` | [[My Todos]]
Enter fullscreen mode Exit fullscreen mode

Breakdown of the Code:

  • dv.page(...) loads the referenced file (My Todos in this case).

  • .file.tasks accesses the tasks within that file.

  • .filter(t => t.completed).length counts the number of completed checkboxes.

  • .length counts the total number of tasks.

  • The || 0 ensures the display remains stable even if no tasks exist, preventing errors.

The Result

With this snippet in place, my dashboard now displays:

Aleksandar’s tasks

This provides a real-time overview of my task completion status without requiring manual updates.

Why This Works Well

  • Dynamic Updates – As tasks are checked off or added, the numbers update automatically.

  • Minimal Setup – No additional scripting or plugins beyond Dataview are required.

  • Clear Overview – Helps track progress across multiple files without opening each one manually.

Potential Enhancements

If you manage multiple task lists, you can modify the query to aggregate counts across multiple files or folders. Additionally, Dataview’s table view could be used to show progress for several projects at once.

If you use Obsidian for task management, consider implementing a similar solution to enhance visibility and productivity.

Top comments (0)