One file and one key, multiple values

Things I have tried

I’m trying to add multiple values to a key…

subject: biology, psychology

subject: “biology”, “psychology”

is that possible? Dataview recognizes it as one value instead of two.

What I’m trying to do

I want 1 file to appear (subject: biology, psychology) to appear in 2 dataviews:

where subject = “biology”
where subject = “psychology”

Like this?

---
subject: 
 - biology
 - psychology
 - physics
---
# 1. biology

```dataview
TABLE
	filter(subject, (l) => l = "biology") as Subject
WHERE 
	file.path = this.file.path
```

# 2. psychology

```dataview
TABLE
	filter(subject, (l) => l = "psychology") as Subject
WHERE 
	file.path = this.file.path
```

See: Arrays

Given that you’ve sorted out the definition of the lists, you also need to be able to pick out one of the a where clause. The syntax you’ve shown is for when the subject has one and only one value. When you switch to multiple value you need to change into something like:

where econtains(subject, "biology")

I like to use econtains() as it tests for the full text in your list of values. You can use contains(), but then something like contains(subject, "logy") would match both values, which could be a useful side effect, but in most cases I find that would introduce false positives, so I use econtains().

1 Like

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