Dynamic Dataview query based on meta-button show to much data

What I’m trying to do

I’m trying to filter files based on two property fields
I have two meta-bind drop downs: Type & Provincie

I would like to see data based on:

  • Type (only type)
  • Provincie (only provincie)
  • Type and provincie

Things I have tried

Played around with all possible (for me) options of AND or OR and ()

  • Type works alone
  • Provincie works alone
  • Setting both values gives me all of Type & Provincie ( I need the exact match of both)
Table type, gemeente, provincie, tags AS Status 
	from #foto AND -#foto/fotowalk AND -#foto/done AND -#foto/lookback
	where  type = this.file.frontmatter.type OR 
			provincie = this.file.frontmatter.provincie  OR 
		(type = this.file.frontmatter.type AND provincie = this.file.frontmatter.provincie)
		AND file.name != "Foto - To Visit" 

Not sure if this is even possible ( tried even chatGPT)

Intuitively I feel this should work:

```dataview
Table type, gemeente, provincie, tags AS Status 
from #foto AND -#foto/fotowalk AND -#foto/done AND -#foto/lookback
where file.name != "Foto - To Visit"
  AND (type = this.type OR provincie = this.provincie)
```

But it do depend on the type and provincie being single value properties. If they’re lists in either the file you have this query in, or in the common file set, you need a different query.

So if the query above doesn’t work, please show some examples on typical values for type, this.type, provincie and this.provincie.

I’m afraid it does not work.
Yes the values are text fields

The reason for the dynamic filtering is for certain subjects or region, or subjects in that region.

This is my main overview, I use the Type and Kies provincie dropdowns to fill in the Properties.

Each file has following:


The Type list, contains subject for photography

INPUT[inlineSelect(
class(float-left),
option(null,Type),
option(Architectuur),
option(Alles-is-vergankelijk), 
option(Begraafplaatsen),
option(Landschappen),
option(Gebedsplaatsen),
option(Landbouw),
option(Water),
option(Panorama)
):type]

The Provincie list, is a geographic region

INPUT[inlineSelect(
class(float-left),
option(null,Kies Provincie),
option(Antwerpen),
option(Limburg),
option(Oost-Vlaanderen),
option(Vlaams-Brabant),
option(West-Vlaanderen),
option(Henegouwen),
option(Luik),
option(Luxemburg),
option(Namen),
option(Waals-Brabant)
):provincie]

It might that the issue is that the query is to open if you don’t give that category a value, so try this instead as it seems to work for my simple test cases:

```dataview
TABLE type, provincie
WHERE file.name != "Foto - To Visit"
  AND (this.type = null OR type = this.type)
  AND (this.provincie = null OR provincie = this.provincie)
```

The reasoning is that we only display a file:

  • it it’s not the current file
  • and either the type is not set, or identical to that of the file
  • and either the provincie is not set, or identical to that of the file

This might still show to many files, if some of your files doesn’t have set a value of either of the properties. In that case you should change the meta-binds in the query file to have an extra value for “all” , and change the this.type = null to this.type = "all and similar for provincie.

Thank you holroy, it’s perfect !

Now I can speed things up, as I have a exhibition coming up in June. And I feel I need some more work.

Hopefully you did not put to mutch work into it.

1 Like