How to generate "tasks" from tag in specific folder(s) with Dataview pluggin?

Things I have tried

Closest I’ve gotten:

TASK FROM "Law School/JUR 311 Evidence/Notes"

But it pulls all tasks from that file folder, instead of just the ones that are premised with the #Question tag.

I have also tried the following but it comes up blank…

TASK 
FROM "Law School/JUR 311 Evidence/Notes" or "Law School/JUR 311/ Evidence/Lectures"
WHERE contains(text, "#Question") 

What I’m trying to do

I’m in school and using obsidian for note-taking. While making notes I often have questions and would like to type out the question in my notes and include the following:

#Question

  • [] This is a question I have on the material at this point…

Then in a separate file, I’d like to use the Dataview plugin to pull all the questions I have. I categorize my notes into class-specific folders (i.e. separate folder for Evidence Notes and Civil Procedure Notes) so it would be nice to have a “Question” file specifically for questions I have for that particular class.

I’m not sure how to modify the code block to achieve this. If anyone can help I’d greatly appreciate it!

Hi.

To achieve what you want you need to clarify many things because the main issue could be in the structure of your notes and not in the query.

  1. Your first query gives you all the tasks in all the notes in your folder Law School/JUR 311 Evidence/Notes. Why? Because the only filter you add to the source (the FROM) is the folder.

  2. In your second query you define the source (tasks in one folder or in the other). But you add another filter - WHERE contains(text, "#Question")- that only works if you put your tags in the task text like this:

- [ ] this is true? #Question

“text” is a task-level implicit field, i.e., the content of each task. For now is the only content you can query in DQL dataview, because the general content of the note you can’t.

  1. If you add the tag before the task or in other place of your note, this tag it’s a page-level metadata, not a task-level metadata. Of course you can query for tasks in pages with specific tag (FROM #Question) but you get all the tasks in that page, not only the ones “under”/ “next” your #Question tag.

  2. For your goals, I think you have two ways: 1) using tags (or an inline field) in the tasks content or 2) put your question tasks under a “## Question” heading (h1, h2, h3,… header level doesn’t matter), because it’s possible to query the tasks inside a specific header/section.

1 Like

Thank you for your response and thank you for clarifying! Including the #Question tag at the end of each task works perfectly!

And yes, to answer your first question - I use the checkbox feature for other reasons and it was populating with all instances instead of just the ones following the #Question tag.

As well, how would I modify the syntax in the dataview query to draw tasks categorized under a “Question” header? Would I have to still write the questions as a checklist or would the dataview plugin just pull all text within that header?

Thank you for your help, I appreciate it!

If you define the header in your query, than dataview pull all tasks within that header. But if you want just some tasks (not all within the header), then you need to add another filter (tag, inline fields, etc.)

To filter tasks within “Question” header you can use this:

TASK
FROM "Law School/JUR 311 Evidence/Notes"
WHERE meta(section).subpath = "Question"
3 Likes

Thank you!

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