Next unchecked task in a section with a tag

First time poster, please forgive me if I break some rules, but I think I’m legit.

What I’m trying to do

I’m trying to include only the first task with a tag of #nextAction from projects if it isn’t completed. I may have multiple #nextActions in the list. For Example.

- [ ] Action 1
- [ ] Action 2
- [x] Action 3 #nextAction
- [ ] Action 4 #nextAction

I only want it to return action 4

Things I have tried

I’ve searched the forums, loaded the Example Vault and even tried ChatGPT. I’m still pretty new to this

Here is test query 1.
This is the closest I have come to succes. This returns multiple lines for the same file. One for each tag that contains #nextAction

Table  
	file.name,
	replace(nextAction.text, "#nextAction", "") as "Next Action" 
From 
	"Test_Projects" 
	flatten file.tasks as nextAction
Where
	nextAction.completed = false AND
	contains(nextAction.text, "#nextAction")	

Here is test query 2.
This only returns a result if the first task has the tag and is unchecked.

Table  
	file.name,
	replace(nextAction.text, "#nextAction", "") as "Next Action" 
From 
	"Test_Projects" 
	flatten file.tasks[0] as nextAction
Where
	nextAction.completed = false AND
	contains(nextAction.text, "#nextAction")	

The first query looks the most promising. I would change the last three lines to:

Where
	nextAction.completed = false AND
	Tags, "#nextAction")
Limit 1

This would so the tag search in the actual tags, and it’ll return only one result. You might need to sort the tasks to get the correct task, but normally it do return them in the file order .

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