Dataview WHERE a certain Checkbox is checked

What I’m trying to do

I want to list all files, where a certain Checkbox is checked. I have a set of fixed todos per event and only want to list events, where a checkbox is not checked yet.

What I have tried

FROM #events
WHERE contains(file.tasks.text, "To Do 1") 

is showing all files with that todo, but I can’t figure out to list only the ones, where the Checkbox of the Task “To Do 1” is not checked yet.

I think you need to do a little more complex query.
In your query it checks if any task in your note have the text “To Do 1”.
But in that way you can’t filter at same time two conditions in the file.tasks level.

You can try two ways:

  1. using the same logic but filtering inside the array file.tasks
FROM #events
WHERE filter(file.tasks, (t) => contains(t.text, "To Do 1") AND !t.completed)
  1. using the FLATTEN command to filter directly in the tasks level:
FROM #events
FLATTEN file.tasks AS Tasks
WHERE contains(Tasks.text, "To Do 1") AND !Tasks.completed
1 Like

Thank you. The first solution fits more into my thinking :slight_smile:

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