GaFeh
March 25, 2025, 5:47am
1
Hi, I want to create a dataview search, that I can easily customize or configure with a property.
So, instead of something like this:
```dataview
table week AS Woche, title AS Titel, url, tags
from "Texte" AND #agency
sort file desc
I would like to have something like:
---
SearchTag: agency
---
```dataview
table week AS Woche, title AS Titel, url, tags
from "Texte" AND this.SearchTag
sort file desc
How to do that?
Thanks
Gab
I’m not sure if plain Dataview can work dynamically to get tags from the Frontmatter. But I’m sure that experts will correct me if I’m wrong
Would you dare to try using DataviewJS ?
```dataviewjs
const tag = dv.current().SearchTag;
dv.table(
["Woche", "Titel", "URL", "Tags"],
dv.pages('"Texte"')
.where(p => p.tags && p.tags.some(t => t === `#${tag}` || t.startsWith(`#${tag}/`)))
.sort(p => p.file.name, 'desc')
.map(p => [p.week, p.title, p.url, p.tags])
);
```
Cheers, Marko
1 Like
Hello.
This works in a local test vault:
```dataview
TABLE
week AS Woche
, title AS Titel
, url
, tags
FROM "Texte"
WHERE SearchTag = this.SearchTag
SORT file desc
```
Does it work for you?
1 Like
GaFeh
March 25, 2025, 9:02am
4
anon80950206:
```dataview
TABLE
week AS Woche
, title AS Titel
, url
, tags
FROM "Texte"
WHERE SearchTag = this.SearchTag
SORT file desc
Tanks for your support. Unfortunately not. The entry in the “SearchTag” should search among the tags, but
```dataview
TABLE
week AS Woche
, title AS Titel
, url
, tags
FROM "Texte"
WHERE tag = this.SearchTag
SORT file desc
won't work.
The question for me is: how can I search among the tags?
Hello.
Is this what you need?
```dataview
TABLE
week AS Woche
, title AS Titel
, url
, file.etags as "tags"
FROM "Texte"
WHERE any(contains(file.tags, this.SearchTag))
SORT file desc
```
1 Like
GaFeh
March 25, 2025, 1:40pm
6
It is, indeed. Thanks for that hint.
1 Like
holroy
March 25, 2025, 6:45pm
7
Just to mention that case as well, if you want to search for a property given in another property. Aka if you wanted to search in the SearchProperty for SearchValue, you could do something like WHERE row[this.SearchProperty] = this.SearchValue.
1 Like
system
Closed
April 22, 2025, 6:45pm
8
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.