Help with Dataview query issue comparing a link format to non-formatted

What I’m trying to do

I’m really struggling to create a basic table query in Data view. Here’s the simple query I’m attempting:

dataview
TABLE
FROM "Data/Primary/DB Bookmarks"
WHERE projects = this.file.name

I have a ton of notes in the DB Bookmarks folder, and each has a property called “projects”. In a project file, I’m wanting to query all the bookmarks related to that individual project.

The problem, I think, is that all of my properties are also links to other notes, so in YAML, in a bookmark page, the “project” field is: “[[Anim Vendor - Talent Database]]”, while the project file name is just plain old “Anim Vendor - Talent Database”.

Things I have tried

I tried to use a function to somehow remove the brackets so there is a direct comparison, but to no avail. Any ideas would be super appreciated.

table url, domain, archive
FROM "Data/Primary/DB Bookmarks"
WHERE replace(replace(project, "[[", ""), "]]", "") = this.file.name

Thanks in advance.

1 Like

If your key projects is a text type of key, I think you could try to use this.file.link (which is another metadata implicit field) or maybe something like link(this.file.name) (link()'s doc) :thinking:
(This is untested though :innocent: )

If the key projects is a list, then you’ll most likely need to use contains() instead of = :blush:

1 Like

Holy cow THAT WORKED! Thank you so much! Sincerely appreciated. My mind is blown.

1 Like

@Pch Sorry to bother again. One hiccup I’m having is that this query seems to only work for existing links between notes, but not for new ones I create. Can’t explain it. Attached are some picture to show the issue. Basically, I created a “Test Linked Bookmark” note to link to another note via a “project” custom field. For some reason, it never appears.

Thanks a ton in advance.



I honestly can’t repro the issue in my small test vault :thinking:
Whatever I do, the query is refreshed :thinking:

But seeing on the screenshots that the projects key is indeed a list, maybe you could try this :blush: :

```dataview
TABLE
FROM "Primary/Bookmarks"
WHERE contains(projects, this.file.link)
```
2 Likes

You are truly a genius. Thank you so much!

1 Like

You’re kind of contradicting yourself, as you are presenting both pure text variants of the projects property and list variants.

Are you sure you’re only using just one variant or are you using both?

In the latter case, you’d be better off with a construct like contains( flat(list(projects)), this.file.link) which should work in either case.

1 Like

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