How to create a Table of TASK depending on multiple tags

Don’t get me wrong, but do you read the plugin documentation? Dataview

You can’t take a task query and translate it directly to a table query! Why? Because in tasks queries you can work simultaneously in two different levels of metadata: page level as task level. In table queries you can’t work directly in tasks levels…

An example: if in task query you can target the task text only with text, in tables you need to target it with file.tasks.text.
https://blacksmithgu.github.io/obsidian-dataview/data-annotation/#implicit-fields

Looking to your query:

  • What’s Tasks.text? I guess you see somewhere (in other post) this Tasks as field. But to use that you forgot other expressions in the code (maybe a FLATTEN file.tasks AS Tasks).
  • What you want to do with the functionregexreplace()?
  • You can’t use “where” in that way. In first place, you can’t use text because you are not querying in tasks level, but in page level (text = file.tasks.text?). Second, you can’t add two conditions inside the same contains expression (maybe two contains clauses).
  • I guess you need to use the FLATTEN command and decide if you want to see tasks text grouped by file or alone (with the repetition of the file.link)

Filter for one tag:

TABLE rows.Tasks.text
FROM "journal"
FLATTEN file.tasks as Tasks
WHERE contains(Tasks.text, "#problem")
GROUP BY file.link

Filter for two tags (AND means both conditions true, i.e., you need to have both tags in the same task text):

TABLE rows.Tasks.text
FROM "journal"
FLATTEN file.tasks as Tasks
WHERE contains(Tasks.text, "#problem") AND contains(Tasks.text, "#aquarium")
GROUP BY file.link

Filter for two tags (OR means tasks with one tag OR other OR both)

TABLE rows.Tasks.text
FROM "journal"
FLATTEN file.tasks as Tasks
WHERE contains(Tasks.text, "#problem") OR contains(Tasks.text, "#aquarium")
GROUP BY file.link

You can’t copy code to solve your goal without a minimum of knowledge about what in stake. Or better, you can do it but you don’t learn anything. In one future plugin update something change, your queries broken and you don’t understand why… And everything return to stage zero.

2 Likes