I’m trying to find the best way to limit (multiple) dataviewjs queries depending on a field (from the frontmatter) in the current file. I want this dynamic, so as not having to change a set of 5-10 queries on these pages.
Things I have tried
My index/MOC note has the following field defined:
However, the first one requires rewrites every time I move to a new month, and the second one I just kind of don’t like, so I’m wondering if you’ve got any suggestion to fix the last variant where it does look up the todoPeriod field, but the query looks a little nicer?
PS! These are simplified queries, and I do manipulate the tasks more to filter of statuses, sorting, and even some post-processing in some of the queries. So I do need to keep a similar structure with first doing the query into tasks, and then a presentation step, like with dv.TaskList(tasks, false) afterwards.
The only sad thing is that it doesn’t work. Not sure how to debug this query either to see whether the file.etags is actually set or not. Or whether to use this.todoPeriod or just todoPeriod.
The metadata documentation doesn’t mention how to get the file’s metadata outside of the task. So stuff like tags refers to tags inside the task.
I’m a bit stumped by this. I know I can change everything into some dataviewJS query, but it should be possible to do this in a plain DQL-query, as well.
Update: I’m a bit of an idiot. I changed to todoPeriod: #Year/2022/11, which failed. With the original todoPeriod: Year/2022/11, your solution, @mnvwvnm with contains(file.etags, this.todoPeriod) does indeed work.
Tasks queries in DQL are confusing because they work at same time in both levels: page/file level and tasks level. That’s why we need to pay attention about a potential conflict with field keys: tags is one example.