# Query page's content based on heading and tags

**URL:** <https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643>\
**Category:** Help\
**Created:** [August 23, 2023, 4:55pm UTC](https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643 "2023-08-23T16:55:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wenzel](https://forum.obsidian.md/user_avatar/forum.obsidian.md/wenzel/32/87300_2.png) [@Wenzel](https://forum.obsidian.md/u/Wenzel)\
**Post date:** [August 23, 2023, 4:55pm UTC](https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643/1 "2023-08-23T16:55:37Z")

</div>

Hi,

I’m opening this topic following @kepano’s recommandation from [Twitter](https://twitter.com/kepano/status/1693547464165634113).

My main use case with Obsidian is to build periodic reports based on the daily notes I write.

My daily notes are written with the Periodic Notes plugin, with the following path:

Journal/YYYY/MM/[W]ww/YYYY-MM-DD

So for example: `Journal/2023/08/W34/2023-08-23`

In my Daily note, I have multiple section with bullet points in a hierarchy:

```markdown
# Thursday, 24th August
## Bugs to Address

- Replicate reported UI glitch in the settings menu
- Debug API response for the user profile endpoint
    - Check if it’s an issue with the database query
- Data synchronization bug in the mobile app is #done

## New Features to Implement

- Design the new user dashboard layout
- Code the authentication flow for the new SSO integration

```

→ How can I create a weekly report and extract the content of the `Bugs to Address` section, while keeping the bullet point structure ?

I found the following topics have potential solution: [Query bulleted dates and/or tag under a specific header: advice](https://forum.obsidian.md/t/query-bulleted-dates-and-or-tag-under-a-specific-header-advice/56085)

Which is to combine `FLATTEN` and `meta` in order to filter on the heading.

Possible solution:

```auto
LIST rows.item.text
FROM "Journal/2023/08/W34"
FLATTEN file.lists as item
WHERE meta(item.section).subpath = "Bugs to Address"
GOUP BY link(file.name)

```

However, this will break the bullet points nesting structure.

My question is: how can I do that ?

@kepano 's proposed solution to use the transclude feature would work:

```markdown
# Weekly report

## Bugs to address

- ![[2023-08-23#Bugs-to-Address]]
- ![[2023-08-24#Bugs-to-Address]]
...

```

However you miss the power of the query language to filter on specific tags (for example #done)

So i’m not sure how to address this ?

Thank you in advance !

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [August 23, 2023, 10:24pm UTC](https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643/2 "2023-08-23T22:24:11Z")

</div>

Moved from Bug Reports to Help.

---

<div class="post-metadata">

**Author:** ![CawlinTeffid](https://forum.obsidian.md/user_avatar/forum.obsidian.md/cawlinteffid/32/82899_2.png) [@CawlinTeffid](https://forum.obsidian.md/u/CawlinTeffid)\
**Post date:** [August 23, 2023, 10:25pm UTC](https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643/3 "2023-08-23T22:25:39Z")

</div>

If you format the list as [task list items](https://help.obsidian.md/Editing+and+formatting/Basic+formatting+syntax#Task+lists), I believe you can use the Tasks community plugin to do what you want.

```markdown
# Thursday, 24th August
## Bugs to Address

- [] Replicate reported UI glitch in the settings menu
- [] Debug API response for the user profile endpoint
    - [] Check if it’s an issue with the database query
- [x] Data synchronization bug in the mobile app is #done

## New Features to Implement

- [] Design the new user dashboard layout
- [] Code the authentication flow for the new SSO integration

```

---

<div class="post-metadata">

**Author:** ![Wenzel](https://forum.obsidian.md/user_avatar/forum.obsidian.md/wenzel/32/87300_2.png) [@Wenzel](https://forum.obsidian.md/u/Wenzel)\
**Post date:** [August 26, 2023, 9:49am UTC](https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643/4 "2023-08-26T09:49:42Z")

</div>

Hi @CawlinTeffid ,

thank you for your answer !

Indeed I could reuse the task list items, and use the `headings` filter to extract the section I want.

However, my notes are not limited to task lists, they are more like logs or journals.

That’s why I want a more powerful way of querying a section with Obsidian native queries.

In the meantime I managed to build a solution based on @kepano 's suggestion with transclusion and dataviewJS:

```javascript
const curdate = moment("{{date:YYYY-MM-DD}}");
const section = ' 📖Log'
// Journal/2023/Q3/08/W34
const weekpath = `Journal/${curdate.format('YYYY/MM/[W]ww')}`;
const daily_notes = dv.pagePaths(`"${weekpath}"`);
for (const day_path of daily_notes) {
    //const day_name = dv.page(`"${day_path}"`).file.title;
    // 2023-08-26
    const day_str = day_path.split('/')[4].split('.')[0];
    // Saturday
    const day_name = moment(day_str).format('dddd');
    // [[Journal/2023/08/W34/2023-08-26|Saturday]]![[Journal/2023/08/W34/2023-08-26# 📖Log]]
    const trans_daily = `[[${day_path}|${day_name}]]![[${day_path}#${section}]]`;
    dv.paragraph(trans_daily);
}

```

Which rends as:

 ![image](https://forum.obsidian.md/uploads/default/original/3X/6/d/6d46194446d5f1a7e00d054966122586d082eefb.png)

So it works so far.

I would like to highlight this feature request:

> [@Rename, name, or hide transclusion block titles](https://forum.obsidian.md/t/rename-name-or-hide-transclusion-block-titles/48753):
>
> Use case or problem I haven’t been able to find another FR for this, but I think transclusions go by a few other names so perhaps my searching simply hasn’t found an already brilliant FR for this. I would like to be able to rename the header in header-linked transclusions to improve the ‘flow’ of reading my notes. Similarly I would like to be able to entirely hide the header. This could be achieve ergonomically and intuitively using the pipe operator in the transclusion link. Proposed soluti…

Because I would also find it very useful to rename the ‘Log’ header in my transclusion to the day’s name.

No way to filter on tags here however.  
And the dataview query is brittle and complex to maintain.

Would be happy to receive feedback !

PS: I have one bug to report, when the first report is generated with the transclusion, the transclusion works, and then switches back to “non transclusion” anymore, as if the files didn’t exist. (??)

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [November 24, 2023, 9:50am UTC](https://forum.obsidian.md/t/query-pages-content-based-on-heading-and-tags/65643/5 "2023-11-24T09:50:23Z")

</div>

Closed on November 24, 2023, 9:50am UTC

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