Query FROM a YAML value

On notes A, B, C, G, L, M5, H33, etc, I want list all the notes that link to a primary note called A Book. I can write the Dataview query as below and it works.

```dataview
LIST FROM [[A Book]]
SORT file.name ASC
```

However, I want to store the title of the primary note in the YAML of notes A, B, C, G, L, M5, H33, etc, such as:

---
source: "[[A Book]]"
---

Rather than creating a specific Dataview query with the title of the primary note hard-coded, I would like to create a generic Dataview query that I can paste into thousands of old notes, pulling the title of each primary note from a YAML key instead:

```dataview
LIST FROM this.file.source
SORT file.name ASC
```

This doesn’t work. I have also tried WHERE queries without any joy.

Can it be done? I feel like it should be possible but that I am somehow not seeing an obvious answer.

Thanks for any tips.

Of course it is possible … when two brain cells finally connect:

```dataview
LIST 
	WHERE file.frontmatter.source = this.file.frontmatter.source
	SORT file.name 	ASC
```

Writing it out here on the forum clearly helped me to focus. Thanks, forum. :rofl: :heart_eyes: :crazy_face:

2 Likes

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