Dataview tags of the file

Hello,

I would like to show with dataview the files located in some folder with tags of the actual file.

For example I have the following file with dataview query:


Tags: rice, tomatoes, onion

To make recipe you need to cook…

Other recipes with this ingredients:

LIST FROM "folder/name" AND this.file.tags


But the query shows a parsing failed error.

I tried too:

LIST FROM "folder/name" 
WHERE this.file.tags

This query works but show all files of the folder, in my case I would like to show only the files of that folder with the tags of the actual file: rice, tomato, onion.

If I use the query:

LIST FROM "folder/name" AND #rice AND #tomatoes AND #onion

This works, but because I use a template I don’t like to write tags again every time.

What is the correct query?

Thanks

What I’m trying to do

1 Like

Hi,

Try doing this:

LIST FROM "folder/name" 
WHERE contains(tags,this.file.tags)
1 Like

Thank you for your answer, but doesn’t work. Same result that this query:

LIST FROM "folder/name" 
WHERE this.file.tags

Show all the notes of the folder.

I couldn’t find any information about the function this.file.tags on the dataview documentation. I founded it in some answers of this forums.

???

Maybe you should try the code @Shiinii proposed and not your own one…

However, a small adaptation of Shiinii’s code is necessary - it has to be:

WHERE contains(file.tags,this.file.tags)

1 Like

I think this probaly work

LIST FROM "" 
WHERE contains(tags,[[]].tags)

If there is other food that contains same ingredients is goin to show.

But probaly is goin to have a problem where it need to be in te exact order

1 Like

Sorry I didn’t explain me well, my English isn’t good I tried his code but because didn’t work, I said that the query result shows same of my query.

I tried your query but shows too all the files of the folder.

Thank you

Thank you @Shiinii this query works perfect, but I have to use YAML metadata. If I use normal #tags doesn’t work, again shows all the files of the folder. But this solution it’s perfect too.

Thanks so much

1 Like

Sorry, another small adaptation I forgot to mention:

if you are using more than one tag, you have to write:

WHERE any(contains(file.tags,this.file.tags))

This solution searches for both front matter and inline tags.

1 Like

Thanks so much @alltagsverstand this query works perfect and with #tags, I don’t need to use metadata.

Thank you!

1 Like

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