Query predicate for filtering out empty tasks

I have daily note templates that I use with an “Action Items” section that’s a task list. In the template, I prefer creating an empty checkbox so that I can easily write something and hit enter for the next item. But this has the unintended effect of empty tasks appearing in my task queries for all my daily notes.

Example below:

### Action Items
- [ ] 

I looked high and low at the query syntax and also the JS syntax (and even the source code)! to find how to reference and filter out the task contents itself.
Since it took me too long to find, I figured I should leave it here for others, as I tried opening a PR to the repo and couldn’t find a sensible place in the doc to share the existence of this simple predicate.

I hope it’s useful to someone!

TASK FROM "Daily Notes"
WHERE 
	!completed
	AND contains(string(section), "Action Items")
	AND text != " "

TLDR; All you need to do is assume the text keyword is the task text. You could also use this with a contains(text), "foo") for a partial match. AFAIK, this isn’t documented anywhere in the plugin docs.

1 Like