this post was submitted on 17 Jun 2023
12 points (100.0% liked)

ObsidianMD

4118 readers
10 users here now

Unofficial Lemmy community for https://obsidian.md

founded 1 year ago
MODERATORS
 

I have a number of individual notes for various books I've read, with a YAML field for "author." This works great with Dataview, except when there are multiple authors of a book. I assumed I could just add another YAML line "author: Sample Author" to add the second author, but then Dataview does not return results for either author.

Does anyone know how to change my query so it will return results for either author? Is this possible?

My current search is:

dataview TABLE without ID link(file.link, title) as "Title", author FROM #books Where author = "Sample Author"

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 7 points 1 year ago (8 children)

Just mentioning to cover all the bases: you'll want to make sure you're using the correct multi-value YAML syntax in your front-matter when you include multiple authors (eg. single line or multi line array). I like using the Linter plugin to help me out with this.

# single-line array
author: [Sam Jones, Mary Apple]

# multi-line array
author:
- Sam Jones
- Mary Apple

Once you have something like the above, using flatten should enable returning results for either author; with one test file in my vault, this worked for me:

TABLE WITHOUT ID
link(file.link, title) as "Title", author FROM #books FLATTEN author WHERE author = "Sam Jones"
[โ€“] ReclusiveExtrovert 3 points 1 year ago

That did it! Thank you so much!

load more comments (7 replies)