Dataview: How to write a property with parentheses in its name to contains(...)?

Hi!

What I’m trying to do

I have a property named subject (project sub-activity) which has property type > list.

I want to display with dataview all files that contain the property subject (project sub-activity) and the specified value in this property.

Things I have tried

Usually in cases like this, I use

```dataview
LIST
WHERE contains(subject (project sub-activity), “project 00”)
.```

… and everything works fine, but with parentheses in the property name dataview gives an error:

I tried enclosing subject (project sub-activity) in:

  • ``
  • [] (including using econtains instead of contains (because the dataview documentation used square brackets in econtains, not contains))
  • {}
  • ""

… but it didn’t lead to any result - only errors.

I tried to find a similar example both in the dataview documentation and on the forum, but the most similar thing I could find was this:

contains(list(1, 2, 3), 3) = true /* (in the dataview documentation) */

… and with that I still couldn’t write a working query.

If anyone knows how to write properties with parentheses in the name, please advise…

Thanks.

Just to point out the obvious: it might be easier to change the property names to something like subject-project-sub-activity. No spaces, no characters that might confuse dataview.

I thought about it when I was trying to write a working query, but without using parentheses the essence of what is written changes, and I wouldn’t want to make such compromises. I’d probably even rather wait for Datacore and try to create a working query by interacting with the UI than change the name of my properties…

As a temporary solution, I use Embedded Search together with Query Control, - it takes a bit of time to run the first time (for indexing?), but it works without any issues.

Using the following test document you could see what Dataview sees:

---
subject (project sub-activity):
- First value
- Second value
---

`$= dv.span(dv.current()) `

And the last section of this should be:
image

As we can see here the property exist both in the unabridged version and as a sanitised value. To access these values you could stuff like:

With parentheses: `= this["subject (project sub-activity)"]`

Sanitised version: `= this.subject-project-sub-activity`

Or in a normal query:

```dataview
TABLE subject-project-sub-activity, row["subject (project sub-activity)"]
WHERE file = this.file
```

The output of these last two queries:

image

2 Likes

Thank you very much for your reply.

I failed to write Dataview Query using row[], - I didn’t quite understand how I can specify a specific value for the subject (project sub-activity) property.

Since I wasn’t sure if row[] in principle supports specifying a value for a property, I tried just referring to the property and the value of the property separately in the Dataview Query:
row[<property>] AND row[<value>].
… , but it gave an error.

However, using WHERE contains(subject-project-sub-activity, “<value>”), I was able to get the desired result.

Once again, thank you very much for your help.


@harr, while, based on holroy’s reply, I was looking for information about row[] in the Dataview documentation, I came across this:

… might find this useful.


Again, guys, thank you all so much!

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