Super basic dataview question: how to list all files with my field in them?

Agreed. In lieu of a better conceptual understanding, I did a little more experimentation.
Here is my YAML (I used key names that did not occur anywhere else in my vault so that I did not have to worry about using FROM to filter.)

---
mainKey:
  keyIWant1: val1
  keyIWant2: val2
---

Then I just made a giant table with different variations. Perhaps you have some more of your own to experiment with!

TABLE WITHOUT ID
mainKey,
mainKey.keyIWant1 AS "withDot",
mainKey["keyIWant1"] AS "withIndex",
mainKey.keyIWant1 = "val1" AS "equals 'val1'",
mainKey.keyIWant1 = val1 AS "equals val1",
keyIWant1 AS "subkey alone",
keyIWant1 = "val1" AS "subkey equals 'val1'?",
keyIWant1 = val1 AS "subkey equals val1?"

Results (reformatted to markdown):

mainKey withDot withIndex equals ‘val1’ equals val1 subkey alone subkey equals ‘val1’? subkey equals val1?
  • keyIWant1: val1
  • keyIWant2: val2
val1 val1 true false false true

Without quotes, val1 (or book-club) is treated as the name of a variable, which if it does not exist as a field name in your file will be some “falsey” (opposite of “truthy”, both apparently technical terms!) value like null or undefined. Not sure which in regular dataview. In the rightmost 3 rows of the table, I tried to access keyIWant1 directly, which does not work. So I get a blank when trying to display its value and internally it is “falsey” (null or undefined). That does not equal “val1”, clearly. But in the rightmost column I am asking if two “falsey” things are equal, and they are!

A correctly formatted field name like mainKey.keyIWant1 or mainKey["keyIWant1"] that has a value in your file will compare its value as you would expect. So in the middle of the table, “val1” = “val1” is true and “val1” = <something falsey> is false.

Does that make sense?

1 Like