Convert this query into something dynamic. I read something that it could be because the links are being seen as lists but when I try something I found that should make the lists into objects… it doesn’t work…
TABLE
WHERE contains(categories, [[PHCM - CCG]]) AND contains(project-status, [[1. Active Project - Next Action]]) AND contains(fileClass, Projects)
Things I have tried
TABLE
WHERE contains(categories, this.categories) AND contains(project-status, this.project-status) AND contains(fileClass, this.fileclass)
Also tried contains(flat(list(property)), this.property)
Here’s an example of my note properties:
---
fileClass:
- Projects
Areas:
- "[[1. PHCM - Billable]]"
Categories:
- "[[PHCM - CCG]]"
Meetings:
People:
Projects:
Project End Date:
Deferred Date:
Delegated Person:
Note Title: CCG - Hub
Support Material:
Date Created: 2025-02-18
Date Modified: 2025-05-06
Knowledge Content:
Attachments:
Project Status:
- "[[1. Active Project - Next Action]]"
Project Priority:
- "[[1. Urgent - Do Today]]"
---
Well, I do have an upgraded version of it in my vault, but I cannot (will not) deconstruct it.
The linked material will get you going, if with some AI help.
I’m not entirely sure what you’re trying to achieve, but it seems like you want to compare a list of links against either a single link, a list with one link or a list with multiple links. All these cases could need special handling.
First of all you’d need to discern if all of your properties are using actual lists or also single valued properties. This could be done using something like:
```dataview
LIST length(rows.file.link)
WHERE fileClass
FLATTEN typeof(fileClass) as fileClass_type
GROUP BY fileClass_type
```
Repeat this query for each of your properties in the appropriate folders if need be, to verify that they all return array. If some of the return just string or link you’ve got some single valued properties, and need to add that exception to the comments below.
If they’re are all array’s, you need to need decided what qualifies as a match. Do you require all or just some of the comparing lists to be equal. Say that your current note has [[a]] and [[b]] as file classes, should they only match against other notes having both of them, or is it enough with just one of them? In either case you would use something like the following to match on it:
WHERE all( map(this.fileClass, (fc) => contains(fileClass, fc)) )
This would require all of them to match, and if you switch to any( ... ) it would require one or more of them to match.
If you need to account for also single valued properties, you’d need to change the last contains() to become contains( flat(list(fileClass)), fc) this would transform any single valued file classes to become a list with a single value, and also to keep those already being lists as a list at the same level.