Dataview plugin not recognizing multi-item YAML list

Hi there!

I’m new to Obsidian and also to this forum so apologies in advance if I’m not posting in the right group.

I started using the Dataview plugin to help organize my index pages.

I’m working on the worldbuilding of a novel and I’d like to add YAML metadata in each note to categorize them according to character, location etc.

My YAML looks like:

---
aliases: []
tags: [character]
type: principal
---

My Dataview query looks like:

LIST FROM #character 
WHERE type = "principal"

It all works great, however as soon as I start introducing several items in “type” metadata, Dataview tells me there are no notes corresponding to the query.

For instance, I change the metadata to:

---
aliases: []
tags: [character]
type: principal, bad
---

With this query, no result is showing. I also tried type: [principal, bad] but same problem.

Any idea?

If you have multiple values in type, you can use these syntaxes:

type: [principal, bad]
type:
  - principal
  - bad

type: principal, bad ins’t the right syntax for multiple values.

Besides that, for type: [principal, bad], types returns a list of two values: principal AND bad. In this case type = "principal" isn’t TRUE (because “type” has also "bad).
When multiple values you can use contains(key, "value"). In you case:

LIST FROM #character 
WHERE contains(type, "principal")

It works, thank you so much!

Weird thing though, when I use single item value like

type: principal

it works, however

type: [principal]

seems to be rejected.

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