Dataview - Query values of inline property without link to file

so I thought it would be neat to note questions in lectures like “Question:: …” and list them at the bottom of the file. This was my first attempt:

LIST Question
FROM "file.path"
WHERE contains(Question, "")

didn’t work.

I tried the solution of other threads:

LIST Question
WHERE Question = this.Question
LIST Question
WHERE (contains(Question, "")) AND (file.name = this.file.name)

both kinda work, but list the current file as a link and questions indented below. kind of ugly, there has to be a better way.

so: how do I only list values of one inline property for the current file?

Would either of these be closer to what you want?

```dataview
TABLE WITHOUT ID
Question
WHERE Question = this.Question
```

```dataview
TABLE WITHOUT ID
Question
WHERE file.name = this.file.name
```

Try this one:

```dataview 
LIST WITHOUT ID Q.text
FROM "file.path"
FLATTEN Question as Q
```

If you use the WHERE file = this.file it’s somewhat more expensive as that has to look through the entire file list of your vault to single out that one file.

thank you for your time and answer! Both work as intended.

Is there any difference I should know about?

thank you too, but unfortunately this one does not work, simply no results at all.

I’ve been looking for a much more efficient way than WHERE file.name = this.file.name (ie. in the FROM clause), but for my purposes it has to be programmatic - I embed a lot of reusable queries across lots of files. I assume you mean a literal string of the file path/name in this example?

Given a file named “test.md” located somewhere in your vault, you should be able to use FROM "test.md" or WHERE file.name = "test.md" (or from within that file itself WHERE file = this.file )

The difference between these are from a logical point of view the following:

  • The FROM needs to scan the file list, and select the properly named file. This should be a lookup in some table, and not very expensive
  • The WHERE variants on the other hand will start of with all files, and prepare each and every file for a WHERE clause, which in this case only limits on the file/filename itself. Theoretically this would mean it’s possible way more expansive, especially given a large vault

The only uncertainty in the discussion above is how much preparation is needed before it can move on to the WHERE clause. But in any case it should be less work than looking at the file set, and ditching all files not matching the name (or folder if that has been used).

I’ve not come around to timing this, and seeing what effect it has to have a small or larger vault. With large I’m thinking in the tens of thousands of files. I imagine that this effect is neglible for any vault with less than a thousand files, but not sure.

1 Like