Hi, I am trying to show tasks which have #nextaction appended to them. But every query I run will only show the file where the tasks are located. I want to display the task itself and exclude any tasks that do not have #nextaction next to them.
For example a file “actions” may contain 3 actions/todos
 action 1
 action 2
 action 3 #nextaction
Where #testtag is whatever folder/criteria you want to filter your notes by. Dataview in its simplest form simply returns tasks from the pages that satisfy your conditions. You can’t apply conditions to the tasks themselves unless you use DataviewJS
Note: your code block would have to start with “dataviewjs”, have a look here for more info
Not true. You can achieve the same goal with simple DQL queries.
WHERE contains(text, "#nextaction")
I just didn’t give the solution in my first post because the need to understand the difference between the definition of the source - the tag as a page level metadata - and the filter of tag in each task (by text or, in new beta version, by tag inside tasks).
With some start query we can explain things; post only the solution it’s less pedagogic.
I actually managed to build a hacky solution to include the checkbox by putting a dvjs inline query in a nextactions field in the queried note. But it seems like an overly complex solution and I actually only need the text of the task and not the checkbox itself.
The main problem is: you want to keep access to other values to get the total and build your progress bar.
If that wasn’t the case, then you could use the flatten command and after apply some where conditions to filter the desired tasks.
But that isn’t the case…
So, you can try something like:
Just to play back what I have learnt (as this was my first foray into using DQL functions):
Step 1: This returns the task objects from each queried file. This is a great way to see all of the key-values associated with tasks so the results can be filtered further or a specific type of value can be returned
Step 2: The filter function returns an array of all of the tasks objects for each queried file. we define this array as t. We then filter out using “!” the task objects where completed = true. filter(file.tasks, (t) => !t.completed)
My mistake when trying to filter file.tasks.text was that I was narrowing it down to the text key-value too early which was preventing me from being able to also filter on other key-values like completed.
Step 3: Further filter down the task objects for each file for all tasks that contain #next in their text key-value. Contains takes the variable t which is our tasks object, we narrow that down to the text key so we are working with the returned text and we want to return the text values that contain “#next”. We then combine that with the not complete filter in the previous step by using the “&” operator.
Thank you so much for sharing this. I’ve been trying to get my project dataview table to work with all this information for a while now. This example answered all my questions, as well as, adding the next action which is so helpful! This is such a great community willing to share their knowledge to those of us just starting out.
Also, what snippet or style setting are you using for your table?