Retrieve list of bullet points and their sub items

I am a teacher, I use daily logs, and in
My daily log I have 1 bullet point per class, specified by a hashtag. Sub-bullet points are the details of my lessons. For example:

Daily/20240125

  • #class1
    • Geometry
    • Test on Pythagora
  • #class2
    • Algebra

Next to those daily notes, I’d like to have 1 page per class, that would display automatically what I did each day with that class. So in my example, I would create a page “class 1”, a page “class 2”, and I’d like the “class 1” page to automatically display, for each day:

20240125 (as a bullet, or as a header)

  • Geometry
  • Test on Pythagora

This would allow me to encode daily activities via daily logs, but when I focus on 1 class, see what they did each day.

I tried the solutions mentioned in the following article, this seemed very close from what I needed, but unfortunately it failed: Possible to just get a flat list of bulleted items that have a certain tag? · blacksmithgu/obsidian-dataview · Discussion #1329 · GitHub

Indeed, the following code only returns 1 bullet point with “class1”.

list without id
L.text
flatten file.lists as L
where contains(L.tags, "#class1")

Is there a way to retrieve all sub-items under the bullet that contains #class1 ?

Thanks a lot!

The trick to this is to focus on picking out the tagged lists items, but displays it’s children. So the following seems to do the trick:

```dataview
LIST item.children.text FROM #class1
FLATTEN file.lists as item
WHERE contains(item.tags, "#class1")
```

In my test vault the output was:
image

Thank you so much!

For my understanding, why is it required to specify

FROM #class1

Since I anyway specify the hashtag I’m looking for in the WHERE statement?

It’s not totally required, but doing the FLATTEN file.lists in the entire vault would expand any lists in any notes, and that is somewhat expensive. By adding the FROM #class1 we limit the set where we take a closer look on the lists.

For the sake of argument say your vault has 10 000 files (which might have even more list items… ), and of those only a 100 is tagged one way or another with #class1, and of those again only 10 have list items correctly tagged. Due to that FROM we’ve reduced the initial set to look through from 10 000 down to a 100, where we still have “misses” on 90 of the files, but hey it’s better to check 10 out of 100, rather than 10 out of 10 000.

In summary, when we’re doing FLATTEN file.lists it’s often wise to try to limit the set of notes we’re working on in order to reduce complexity and speed up the query.

1 Like

And would I dare asking: is there a way to show the latest entries (for example the ones from the last 3 days only)?

Crystal clear! Thanks a lot!

@holroy or, if looking for dates doesn’t work, take the last 2 or 3 bullet points?

Actually limiting on the bullet point level is kind of hard, since we don’t which file has how many items. Limiting on the number of files to present can be done using either LIMIT or date comparisons. So for the last three days given a file.day which works (which it doesn’t currently in my test vault?!), you should be able to use:

```dataview
LIST item.children.text
FROM #class1
WHERE file.day > (date(today) - dur(3 days))
FLATTEN file.lists as item
WHERE contains(item.tags, "#class1")
```

And if we limit to only the last few files having classes:

LIST item.children.text
FROM #class1
SORT file.mday DESC
LIMIT 2
FLATTEN file.lists as item
WHERE contains(item.tags, "#class1")

You could also try exchanging file.day with file.mday or file.cday for modification time or creation dates instead of the one lifted from the file title (at least that is what file.day is supposed to do).

Thanks so much for the detailed explanation!
I know need to learn this file.day , but I’m sure it will work :slight_smile:

Again, thanks!

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