Querying a single tag from a file with Multiple tags using Dataview

Things I have tried

Hi @Obsidian friends

I have tried searching for any post in DataView I could find for information on how to do a Dataview search on multifields (or arrays) but can’t find anything that solves my doubt (not even in the official documentation - Queries - Dataview)

What I’m trying to do

In its essence, assuming that I have this file which has the following tags:
“Personal Growth”, “Time Management”, “Clutter-fighting”

Video in Progress.md

# Inspiring Video on Time Management and fighting against clutter
type:: "video"
status:: "inProgress"
tags:: "Personal Growth", "Time Management", "Clutter-fighting"

## Content
Lorem Ipsum dolor sit amet

I’m trying to do the following Query to find any files within that folder that have been assigned the tag “Time Management” but when I do the following Query, I get a “Dataview: Query returned 0 results.”

```dataview
TABLE type
FROM "Aux/DataView/Files"
WHERE tag = "Time Management"
```

The confusing part is that if I do this:

```dataview
TABLE type
FROM "Aux/DataView/Files"
WHERE status = "inProgress"
```

The note will pop up in the query, so I understand that whereas status has only 1 value, since there is more than one tag assigned to this file, the query fails.

I’ve tried creating the file like this and it still fails

Video in Progress2.md

---
type: "video"
status: "inProgress"
tags: "Personal Growth", "Time Management", "Clutter-fighting"
---
Lorem Ipsum dolor sit amet

I’ve tried pretty much everything I could think of such as:

In the file defining those tags as:
tags:: [“Personal Growth”, “Time Management”, “Clutter-fighting”]
tags:: {“Personal Growth”, “Time Management”, “Clutter-fighting”}
etc

In the query, trying to search for
WHERE contains(tags, “Time Management”)

And nothing seems to let me find that, can someone guide shed some light onto this?
I’d very much appreciate some help :slight_smile:

1 Like

After digging a bit more I found a solution in another post

You can define the file like this:

Video in Progress2.md
---
type: "video"
status: "inProgress"
tags: ["Personal Growth", "Time Management", "Clutter-fighting"]
---
Lorem Ipsum dolor sit amet

Notice the brackets

And only then this search will work:

```dataview
TABLE type
FROM "Aux/DataView/Files2"
WHERE contains(tags, "Time Management")
```
3 Likes

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