Help with Dataview using the new Properties

What I’m trying to do

Since the new update with the Properties:
Screenshot 2023-11-14 at 11.14.07

The notes created after the new update cannot be queried to create dataview tables or lists:

LIST type
WHERE projects = "Testing"

results in:
Screenshot 2023-11-14 at 11.15.42

Now if I query tags in notes created prior to the update:

LIST type
WHERE projects = "Almanac"

I get a proper query
Screenshot 2023-11-14 at 11.16.35

Things I have tried

I searched everywhere for a solution to this but I simply cannot find it.

When I look at the raw .md files, they are slightly different:

---
tags: Research Talks
projects: Almanac
type: abstract
status: draft
date_created: 2023-01-11 - 08:45
---

this one works, while this one below doesn’t:

---
tags:
- Projects
- Research
- Stockholm-University
projects:
- Testing
type: Project
status: ongoing
date_created: 2023-06-05 - 13:38
---

However, since the new update, all the properties added have this second format which doesn’t seem to work with dataview as it used to.

Does anyone know how to update the query in dataview to, for example, create a list of files where the project property is a certain value?

I also changed the type of property of projects to just text and still the query fails.

Thanks!

First of all, the below syntax declares a string property:

projects: Almanac

This syntax, however, declares a list property with one item:

projects:
 - Almanac

which FYI can also be written as an array containing one item:

projects: [Almanac]

They are treated differently in DataView as follows:

  • strings are checked using the = like usual
  • lists are checked using the function contains(list, value) (see more functions here)

So in order for the above dataview block to work, you have to write it like this:

LIST type
WHERE contains(projects, "Almanac")

This checks if the list contains “Almanac” as an item.

However, the contains function also checks for substrings in a bigger string, so it also covers the case of using a string property, which means it will work no matter how you declare that property.

4 Likes

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