Is it possible to count checked/unchecked checkboxes in notes?

I would like to have a summary view of daily tasks - identify productive/unproductive days by counting checkboxes of each state in daily notes.

This might be a good idea for a plugin, but first I wonder whether something like this can be achieved with dataview or by other existing means.

Reference: how tasks are counted in GitHub issues containing checkboxes.
Except, ideally, I would like to have this information collected in a list/table like this:

  • day : :heavy_check_mark::heavy_check_mark::heavy_check_mark::x::x:

First approximation (bare dataview):

TABLE
length(filter(file.tasks, (t) => t.checked)) AS "Done",
length(filter(file.tasks, (t) => !t.checked)) AS "Not done",
round(100.0 * length(filter(file.tasks, (t) => t.checked)) / length(file.tasks), 2) AS "Percent"
FROM "journal"

Transforming numbers to repeating symbols (character bars) will require dataviewjs.

Figured dataviewjs solution with emojis:

dv.table(
  ["Day", "Tasks"],
  dv.pages('"journal"')
    .map(d => [
      d.file.link,
      '✔'.repeat(d.file.tasks.filter((t) => t.checked).length) +
      '❌'.repeat(d.file.tasks.filter((t) => !t.checked).length)
    ]
  )
)

You’re good at finding solutions to your own requests, so I’m just here to challenge you a little:

  1. Can you make it into a DQL query now, if I tell you that you can use FLATTEN to calculate and store values in a query?
  2. And can you then make it into a progress bar, similar to this post?

If you hadn’t solved it yourself, that query could easily have been my response to your request. :smiley:

Thanks.

I don’t need a progress bar, I need one symbol per task.

While figuring out how FLATTEN works, I came to conclusion it is not what I need, and even if there is a roundabout way to use it, it might be not the best idea.

At the same time, I realized DQL can do this:

TABLE
join(sort(choice(file.tasks.checked, "✔", "❌")), "") AS "Tasks"
FROM "journal"

(This way of implicit array handling is not something present in languages I use daily. Convenient for data processing but unsettling.)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.