How to make a dataview query with the name of the current note as a link?

I have a category as a link to a note, I need to make a dataview query to display all notes in which the name of the current note is written in the category.
That is, in the note I have written
category::: [[note1]]

In note1 itself I write the query

WHERE contains(category, [[]])

it doesn’t work, it only works if you remove the brackets [[ ]] both in the query and in the category itself, so that it looks like this
category::: note1
and the working query looks like this

WHERE contains(category,

but then the category is no longer a reference to the note

Instead of this.file.note, try using [[]] I don’t use inline properties for the linking, so that could be part of the issue but dataview queries of that form work for me to do what you want to do.

1 Like

Inline fields should have two colons, not three like in your example above there. Other than that if you want to build a link to check against based on the file name I would rather use either [[]] which was suggested or based on other fields, you could also use link(this.someOtherFilename). The syntax [[my note]] is mostly used for a fixed note name, but it’s slightly unsafe to use (as well as them not being recognised as proper links by Obsidian).

In short, using either [[]] for the current file, property: "[[a note]]" in the frontmatter, or just inText:: [[another note]] is the three most common and useful ways to define links which are respected by Obsidian as proper links.

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