Help with dataview query and note title

I have the following query:

TABLE WITHOUT ID link(file.name) AS "Taak", status AS "Status", prioriteit AS "Prioriteit", persoon AS "Persoon"
FROM "10 - Onderzoeken/Taken"
WHERE taaknr = [[Test]].onderzoeknr
SORT file.name ASC

Now I want to replace [[Test]] with the name of the note.
So that I don’t have to adjust this in every new note.
I’ve tried:
WHERE taaknr = [[file.name]].onderzoeknr
WHERE taaknr = tp.frontmatter.onderzoeknr

I don’t know about the onderzoeknr part, but Dataview has syntax for referring to this file:

You can implicitly reference the current file via [[#]] or [[]] , i.e. [[]] lets you query from all files linking to the current file

https://blacksmithgu.github.io/obsidian-dataview/reference/sources/#links

Can you use that with your metadata?

That is possible, but I have to do it again with every new note. What I’m trying to do is make it happen automatically when creating a new note. Via a template.

The syntax offered by Dataview can be used in a template and then applied (without modification being necessary) to new notes automatically. I use the code below, for example, in a people template to keep track of when I interact with different people. I don’t need to edit the code—the query works on the file name of the file it is used in.

```dataview
LIST
FROM [[]]
WHERE file.name != this.file.name
SORT file.link ASC
LIMIT 100
```

If I create a note called Seagram using this template, the file will populate with all file names of any notes that contain [[Seagram]]. I don’t need to edit the code; it’s all automatic. Not what you want?

No, not exactly. I have a note with a property called ‘onderzoeknr’. So what I want is that the ‘onderzoeknr’ is automatically filled in the dataview. In place of [[Test]].onderzoeknr position.

Hi.

WHERE is used to filter data:

WHERE : Filter notes based on information inside notes, the meta data fields

https://blacksmithgu.github.io/obsidian-dataview/queries/structure/#filter-sort-group-or-limit-results

In your query;

WHERE taaknr = [[Test]].onderzoeknr

You want to filter a taaknr value that matches the file name of the file where the query is placed and the onderzoeknr of which file: the file that links to the file that has the query, or the file that the query is placed in?

So a taaknr is an always a combination of two pieces of metadata that match exactly?

taaknr = file name + onderzoeknr ?

Possible to share some sample YAML and a note of what the output should look like?

Given the file name in your test is “Test”, and you want to use the current file, you should be able to use WHERE taaknr = this.onderzoeknr

No need to go through the file link, which should be available through this.file.link, or in some cases [[]].

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