Query files based on it's linked file's property

I’m trying to filter all files whose linked files falls under a specific category.

```dataview
TABLE WITHOUT ID
file.link AS "Seed Name",
file.etags AS "Type",
dateformat(file.cday, "MMM dd, yyyy") AS "Last watered"
FROM ("ALL-NOTES" AND #01-SEED )
WHERE (length(file.inlinks) = 0 AND planted = true)
SORT file.ctime DESC
```

In the above query, I’ve filtered out files where there are no inlinks.

Instead I want to filter all files that are (of tags:) #01-SEED, and planted (= true), but does not have any inlinked files who are (of tags:) #02-SAPLINGS.

To achieve your goal you’d need to filter the inlinks and verify that none have that tag set. In the post below a similar filter is used. Is that enough to get you over the finish line?

1 Like

Thank you @holroy. I’ve tried to modify that solution for my use case, but keep ending up in an error.

```dataview
TABLE WITHOUT ID
file.link AS "Seed Name",
file.etags AS "Type",
dateformat(file.cday, "MMM dd, yyyy") AS "Last watered on"
FROM #01-SEED 
WHERE planted=true
FLATTEN list(filter(file.inlinks, (inlink) => !contains(inlink.etags, #02-EVERGREEN ))) as UngerminatedSeeds
WHERE UngerminatedSeeds
SORT file.ctime DESC
```

This is the error I’m getting.

Dataview: Error: 
-- PARSING FAILED --------------------------------------------------

  5 | FROM #01-SEED 
  6 | WHERE planted=true
> 7 | FLATTEN list(filter(file.inlinks, (inlink) => !contains(inlink.etags, #02-EVERGREEN ))) as UngerminatedSeeds
    |                                                                       ^
  8 | WHERE UngerminatedSeeds
  9 | SORT file.ctime DESC

Expected one of the following: 

'(', 'null', boolean, date, duration, file link, list ('[1, 2, 3]'), negated field, number, object ('{ a: 1, b: 2 }'), string, variable

I have searched online to find a way to correctly check the property of an inlink but getting nowhere.

I have the default tags property to help denote the “type” of the note I write seed, saplings, etc.

So I’ve tried editing etags into tags but end up having the same error as well.

Thanks for the help, but I was able to figure it out without using the flatten, list or filter functions.

Here’s my learning.

file.inlinks.tags returns array
arrays can work with contains function.
These arrays does not carry the # in the tag! ← this is where I was making a mistake.

WHERE planted = true
WHERE !contains(file.inlinks.tags,"02-SAPLING")

This condition solved everything! I was using #02-SAPLING before which resulted in still giving all the other files who is connected to a 02-SAPLING file.

I’m glad you figured it out, I’m on a place with bad connection so I didn’t see your attempts.

1 Like

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