to see all possible options you get from lists? Instead of lists.section or lists.header for example, you can use lists.text which returns the actual text of the heading section. You can also then use that in the WHERE condition too if you want to match text in the section body or just use the header in the WHERE as you are doing now.
Thank you this helped, but I’m still stuck.
First, I noticed what seems to me to be a bug, but it probably working as designed. I created the [[Simple Test Headings]] file. Headings will not be recognized if they only have plain text after them. They must have at least one bulleted or numbered list under them to be recognized as a list themselves, and so to appear in the queries below.
Blockquote
Heading 1
some heading 1 text.
Heading 2
I. some heading 2 text
Heading 3
a. some heading 3 text
Heading 4
some heading 4 text
I got just the heading text to display, but could not get a WHERE clause to work:
Table of the lists text. Only shows for Heading 1 and Heading 4, because Heading 2 and Heading 3 do not have a bulleted or numbered list in their text.
TABLE file.lists.text
FROM "Test Files/Simple Test Headings"
results:
Table of the lists.header
TABLE file.lists.header
FROM "Test Files/Simple Test Headings"
TABLE file.lists.header
FROM "Test Files/Simple Test Headings"
WHERE contains(file.lists.header, "Heading 4")
Here are more WHERE clauses that return no results
WHERE contains(file.lists.header, “Heading 4”)
WHERE file.lists.header = “some heading 4 text”
WHERE file.lists.header = “Simple Test Headings > Heading 4”
My only wild guess at this point is that “file.lists.header” is not being evaluated in the WHERE clause, or at least is not being evaluated the way I expect.
Any further thoughts?
And again, thanks for your suggestions
It is indeed working as designed. AFAIK, in Dataview there’s no easy way to get text of an entire section. What it does have, which we are using here, and the hint is in the name file.lists.header. We are working with the lists property of the file object. The documentation mentions that this only fetches lists and tasks (which are just a type of list). So fetching heading 2 and 3 in your example would be not possible this way.
Regarding the where clause issue, can you try if this works
TABLE H
FROM "Test Files/Simple Test Headings"
FLATTEN file.lists.header as H
WHERE contains(string(H), "Heading")
There are two things different here, we are using the string() function before comparing the header and using FLATTEN to get each header in a separate row.
That works like a charm! Many Thanks I especially appreciate the explanation, as good explanations like this prevent hours of fruitless experimentation.