Tasks Dataview Query Help

Hey all,

Im unsure why my dataview query is not returning expected results. Can anyone help?

Context:
I use “#task/project/project_name” to arrange my tasks. I then have an master project task list which filters all project tasks. I group them using high, medium and low priorty (e.g. “#priority/high”).

For the master project tasks tracker, the below code works without issue.

TASK
WHERE contains(lower(text), "#task/project")
AND !completed
AND contains(lower(text), "#priority/high")
GROUP BY file.name

However, if I want to have a project specific task tracker, the code does not return results, e.g. it shows there are 0 tasks for that project under that priority. Example of that code

TASK
WHERE contains(lower(text), "#task/project/projectX")
AND !completed
AND contains(lower(text), "#priority/high")
GROUP BY file.name

In the master project tasks tracker, a high priority task for projectX will show up in the tracker, however in the project specific tasks tracker, this same task does not show up.

What am I doing wrong?

Something that could explain why the query doesn’t work for a specific project could be the fact that you lower() the text but not the tag…

I mean, if you lower() the text but use uppercases in your tag, like you did in the example you gave in your post ("#task/project/projectX"), your contains() outputs false and the query is stopped there…

If you lower() the text, you would probably need in that case to lower() the tag within contains() too… or use icontains() to make it case-insensitive (econtains() for an exact case-sensisitve match also exists :blush: )

… or you could also try to use the the tags tasks implicit metadata field:

```dataview
TASK
WHERE contains(tags, "#task/project/projectX")
AND !completed
AND contains(tags, "#priority/high")
GROUP BY file.name
```
```dataview
TASK
FROM #task/project/projectX
WHERE contains(tags, "#priority/high") & !completed
GROUP BY file.name ```

Edit: I was working on a draft and didn’t notice that @Pch already provided you an answer. If you want to learn more about nested tags try this: Nested tags in combination with contains & co

1 Like

Thank you!!

The project names I use are abbreviations (projectX was just an example for this use case) and I used CAPS in the query. Once I changed this to lower case it worked without issue. Great to know and thanks again for you help.

1 Like

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