How does the filter() function work?/is using WHERE as a field possible?

What I’m Trying to Do

Essentially, I’m trying to put a WHERE statement inside a dataview field and filter a list of inlinks–AS a field–where mother-location = file.name. So, notes that link to the current note, but ONLY if they link to it throught the mother-location field.

TABLE filter(file.inlinks, mother-location = file.name)
FROM "Wiki/Locations"

This query doesn’t work, but you can probably see what I’m trying to do.

It seems so simple, and yet I just can’t figure out how this would work. I assume I need to use the filter() function, but I can’t figure out how that works, either.

Things I have tried

I’ve tried this query:

TABLE 
filter(file.inlinks, (x) => contains(x.mother-location, file.name)) AS Sub-Locations
FROM "Wiki/Locations"

I’m not sure if I’m understanding filter() correctly, but I’m trying to filter inlinks to only those where mother-location contains the file name of the current note in the table. So, I’m kind of trying to use WHERE but as a field.

I am very confused as to how to get this working.

Not sure if I understand this correctly, probably contains() could do the trick.

```dataview
list
from "some folder path"
where contains(metadata field, this.file.link)

Yeah, that’s kind of what I am trying to do. Except instead of listing all the sub-locations of one specific mother location, I’m trying to have a table of mother-locations, with the sublocations as a field to the side. That’s why I was wondering if I needed filter() to do that.

But now I’m thinking maybe the only way to achieve this would be to use Group By.

Yup, figured it out. All I needed was group by. I was just thinking of it really weirdly.

TABLE rows.file.link as "Sub-location"
WHERE contains(file.folder, "Location") and mother-location != null
GROUP BY mother-location

Now, I just wonder if I could have nested group by statements…

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