Help building block-level query with multiple conditions (outlinks, specific tags)

I am a recent Roam Research refugee, and I’m very pleased with Obsidian so far. But I’m running into an issue surfacing queries at the block level using multiple conditions and I could use some help or insight as to whether what I want to do is possible! I have been trying to use Dataview and the built-in Obsidian query builder.

Context

I primarily use this for work and I often use my daily notes page to make a number of notations as the day goes on that are not grouped under specific headings. An example of this within my daily note might look like:

2022-11-13

Notes and new tasks

I had a #meeting about [[Project X]]

  • Everyone had some pretty interesting things to say, but I want to hear more from Person A

  • [ ] Follow up with Person A to ask them some questions about [their proposal](external link) before our next meeting.

  • I let the group know I can’t make it to the presentation this Friday, and they will send me the slides later.

Scheduled a #meeting for [[Project Y]] for next month

  • [ ] Write up an agenda and attach to meeting invite

Thinking back later, I made a flowchart to help me remember the process for [[Project X]] and it’s [here](external link) #resources

  • [ ] Remember to go to the grocery store tomorrow and get peas

What I’m trying to do

On the page for [[Project X]], I would like to display results at the block level of queries of all files in my vault that a) have an outlink to the current page in the block and b) contain a particular tag in the block.

For instance, I could surface:

Meetings

I had a #meeting about [[Project X]]

Resources

Thinking back later, I made a flowchart to help me remember the process for [[Project X]] and it’s [here](external link) #resources

Things I have tried

I have searched the forum, subreddit, and GitHub issues list, but the answers I have found are either a) over a year old and possibly no longer accurate; b) not exactly attuned to this use case; or c) recommend implementing a complex dataview syntax that I cannot yet figure out how to extrapolate to my use case. I have also been able to implement the queries below, neither of which does all of the things I am trying for.

(Obsidian search)

tag: meeting

surfaces:

I had a #meeting about [[Project X]]
Scheduled a #meeting for [[Project Y]] for next month

…which is block level! Great! But does not filter out pages not linked to the current page.

(Dataview query)

TABLE FROM #meeting
WHERE contains(file.outlinks, this.file.link)

surfaces:

[[2022-11-13]]

… instead of the block-level content where the elements appear.

I know that block-level content is linkable, searchable and surfaceable (after all, the Linked mentions pane shows references at that level!) but I cannot work out how to embed that into a query, either with Obsidian’s search or what little I can yet understand about Dataview (I’d prefer not to have to dig TOO deep into it). Is this possible? What would the query need to look like? I appreciate any help you can offer!

In case it will help anyone in future, this is what I ended up doing. It has solved most of my issues, although I have not figured out the block-level syntax (in fact am more confused than ever about that), and I wish I could so that I can do more in terms of nested task/list item retrieval. Oh, well.

`dataview

TABLE WITHOUT ID striptime(file.ctime) AS "Date", file.link AS "Link", L.text AS "", kidtext AS "Takeaways"
FLATTEN file.lists AS L
WHERE contains(L.text, this.file.name)
WHERE contains(L.tags, "#meeting")
FLATTEN L.children AS kids
FLATTEN kids.text AS kidtext
WHERE kids.task = false
SORT file.ctime asc

I should also note here that Obsidian only recognizes tasks and true list items (denoted by the - at the beginning), so I had to adjust that in my original sample text.

This returns a table listing all of the notes and subnotes that meet the criteria: link to the current page, contain a specific tag, and are not a task. It displays like this:

1 Like

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