How to create a Table of TASK depending on multiple tags

hello everyone

for my master’s thesis i which to dataview all the problem that i have happen during 3 mounth
i have tagged them with #problem and #aquarium
and i which to gather the note that i have written in a task format (i used kanban) on a table with the task and the date

i can make a list that filter only one tag but not multiple and when i try to change it into a table it"s just doesn’t work

here is my code

TABLE without id regexreplace (Tasks.text, “[.*$”, “”) as Task, file.link as “File”
FROM “journal”
WHERE contains(text, “#problem” and “aquarium” )

ps: i’m new to obsidian and very bad at coding , but i feel it is something that could help me a lot in the futur

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.

1 Like

wow thanks you so much for your explanation
it work perfectly

to be faire i have no experience of coding so i just took some sample on the internet and tried to make my code with it

i wish to learn more about the dataview coding but i can’t find any video or post that explain the basic of the plugin

thanks you so much man

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