Yes, this is possible using Dataview. Although we can’t query list items directly using e.g. LIST
, we can still access them through FLATTEN
.
Data
Suppose we have two files in our vault of interest:
# Page 1
- 2024-10-16 Test 1
- 2024-10-17 Test 2
- 2024-10-18 Test 3
- Some other list item
# Page 2
- 2024-10-16 Test 4
- 2024-10-17 Test 5
- 2024-10-18 Test 6
- An unrelated list item
List all items
We can use a simple query to pull out all the list items, and show only the ones that start with a date:
```dataview
LIST Item
FROM "Scratch"
FLATTEN file.lists.text as Item
WHERE regexmatch("^\d\d\d\d-\d\d-\d\d .*", Item)
```
In this query, the FLATTEN command splits each row up, creating a new row for each list item on the page. Then the WHERE clause filters out any rows that don’t start with a date.
Group by page
If you want to group the list by page, you can do so by adding a GROUP BY
command and making a small change to the LIST
clause:
```dataview
LIST rows.Item
FROM "Scratch"
FLATTEN file.lists.text as Item
WHERE regexmatch("^\d\d\d\d-\d\d-\d\d .*", Item)
GROUP BY file.link
```
The GROUP BY
command tells Dataview to return a new set of rows, one for each group, with each one containing the results for that group. So we have to update the LIST
clause to tell Dataview we want to see the Item
for each subrow.
I hope this is helpful. Happy querying!
Craig