Dataview: query sections of notes

I’d like to create a table, one row per files in a subfolder, one column per section in these files.
I have currently 2 different but related usecases

  • I have to prepare user stories for a project
  • I have to prepare architecture principles for a roadmap
    I started these tasks using Excel but ended with worksheets impossible to display on small screens (<15"). And in the end, with Excel, it’s far from practical, having too much text in a cell.
    If I take the example of the architecture principles, I made an obsidian template corresponding to the columns I had in the Excel file.
---
creation-date: <% tp.file.creation_date("YYYY-MM-DD") %>
tags:
aliases: []
index:
parent:
---

Last update: <%+ tp.file.last_modified_date("YYYY-MM-DD") %>

# [[<% tp.file.title %>]]

## statement

## rationale

## implication

## exemption

## reference(s)

## note(s)

But reviewing it with my team, or when preparing a slide deck for management validation, having all these notes is a bit impractical. I’d like, with dataview, to prepare a dynamic index note, one row per files in a subfolder, one column per section. I started with:

| AP file       | statement             | rationale             | implication              | exemption             |
| ------------- | --------------------- | --------------------- | ------------------------ | --------------------- |
| [ap1](ap1.md) | ![](ap1.md#statement) | ![](ap1.md#rationale) | ![](ap1.md#implication ) | ![](ap1.md#exemption) |
| [ap2](ap2.md) | ![](ap2.md#statement) | ![](ap2.md#rationale) | ![](ap2.md#implication ) | ![](ap2.md#exemption) |

As you can guess, that is not dynamic (not even dataview).
Using dataview, I got as far as:

TABLE WITHOUT ID
    index AS "Index",
    rows.L.text AS "statement"
FROM ""
FLATTEN file.lists AS L
WHERE contains(file.folder, "Architecture Principles")
AND !contains(file.name, this.file.name)
AND meta(L.section).subpath = "statement"
GROUP BY file.link

I am now stuck.
Before adding another plugin to my vault (I was thinking about Database Folder), has anyone any lead on the topic?

Thanks, a lot.

One simple question: you know what that query try to “collect”?

Honestly, I got a result, can’t say I understood the process.

But you’re looking for bullet-point lists under each section/header?

(you can filter folders in FROM instead of in WHERE)

You can try Database Folder, but I guess the problem is the same (also because this plugin uses DataView as a search engine): understanding how each plugin works; what are the metadata available; what is the metadata structure; etc.

Sometimes we need to write the notes according to the way the metadata is structured. One example. Per se, sections/headers aren’t metadata fields available to query. (and dataview doesn’t work with full content, only with what is considered metadata.).

The only way to indirectly “target” the sections is via tasks or lists (tasks and lists are implicit metadata and they contain the info about the header under which they are placed).

So, if the content you want to collect under each section are lists, your goal may be achieved. (with a different query).

No, under the headers, the content could be one or more paragraph, w/ or w/o lists.
If I try to illustrate:

---
creation-date: 2022-12-11
tags:
aliases: []
index:
parent:
---

Last update: 2022-12-11

# [[AP1]]

## statement

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

## rationale

Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.

## implication

In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.

## exemption

Aenean leo ligula,
- porttitor eu,
- consequat vitae,
- eleifend ac,
- enim.

Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum.

## reference(s)

- Aenean imperdiet.
- Etiam ultricies nisi vel augue.
- Curabitur ullamcorper ultricies nisi.
- Nam eget dui.
- Etiam rhoncus.
- Maecenas tempus,
- tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.

## note(s)

Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc.

I understand your point, regarding Database folder and especially regarding

Sometimes we need to write the notes according to the way the metadata is structured.

I’d like to avoid the following:

---
creation-date: 2022-12-11
tags:
aliases: []
index: 
parent:
---

Last update: 2022-12-11

# [[AP1]]

statement::Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

rationale:: Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.

implication: In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.

exemption:: Aenean leo ligula, 
- porttitor eu, 
- consequat vitae, 
- eleifend ac, 
- enim. 
Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum.

reference(s)::
- Aenean imperdiet. 
- Etiam ultricies nisi vel augue. 
- Curabitur ullamcorper ultricies nisi. 
- Nam eget dui. 
- Etiam rhoncus. 
- Maecenas tempus, 
- tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum.

note(s):: Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,

, by the way unsure of how it will work w/ multilines.

Try again from scratch, I got the following:

TABLE without id
    (link(file.name+ ".md#statement")) AS statement,
    (link(file.name+ ".md#rationale")) AS rationale,
    (link(file.name+ ".md#implication")) AS implication,
    (link(file.name+ ".md#exemption")) AS exemption
FROM ""
WHERE contains(file.folder, "architecture principles")
AND !contains(file.name, this.file.name)

How could I transclude now?

And regarding filtering folders in FROM instead of WHERE, it will certainly be a better idea, w/ my vault getting bigger, I understand that, I chose for the time being (and as far as my knowledge is) that solution to be able in the future to move freely the folder “architecture principles”.

@projetnumero9 you can get the full text under headings using a Dataview query like this:

2 Likes

You can’t. In regular DQL you can’t embed sections and in dataviewjs you have a function for that but isn’t a reliable/stable solution.

I think the only way is beyond the dataview metadata core. As suggested by @AlanG , you can use javascript inside dataviewjs to get full content via Obsidian api and parse/filter it with regex to select only parts under specific headers.

But I leave this explanations and assistance to erudites in js matters (not my case…).

Thank (both of) you for these enlightenments and leads.
I’ll get back with any progress I’ll make,

boa sorte.

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