Workaround for the non-existing wildcard within a choice-clause in a where-statement

What I’m trying to do

I want to use an inline or yaml property to filter for quests that take place in a specific realm (German: Sektor). If the ‘SektorFilter’ is empty I want to see all #Quest on file.

SektorFilter:: Sommer

Note Structure

I have the following samples of DnD quests.

Goat_Furr-Quest

---
Sektor: Winter
Finished: false
---
Für [[Balthasar Bohnä]] die Felle von seltenen [[Bergziegen]] im [[Winter Domäne (Norden)|Winter Sektor]] sammeln.

#Quest

Frohob_Son-Quest

---
Sektor: Sommer
Finished: false
---
Seit dem Mord an [[Frohob Goldilock]] ist sein Sohn verschwunden. Er hat uns gebeten nach ihm auf unserer weiteren Reise Ausschau zu halten.

#Quest

Infernal_Spider-Quest

---
Sektor:
Finished: false
---
Für [[Swifi Swift, Taylor und Roper]] eine (am besten weibliche) [[Infernal Spider]] mit Kindern auf dem Rücken suchen. Falls wir auch noch ein Männchen finden, müssen wir sie in getrennten Behältern transportieren.

#Quest

Gift_Golden_Dragon-Quest

---
Sektor: Winter
Finished: true
---
[[Thiari]] hat von [[Geribaldi Vetterli]] eine Kiste  aus dumklem Holz und Runen drauf gegeben. Diese soll sie dem [[Goldener Drache|Goldener Drachen]] zum Geburtstag geben.
Ausserdem soll sie ihm Grüsse von Geribaldi ausrichten.

#Quest

Things I have tried

So in SQL (yes, i am aware that Dataview is handled quite differently line by line) i would try something like this:

Pseudo SQL

TABLE WITHOUT ID Sektor, file.link AS "Name"
FROM #Quest
WHERE Sektor = (CASE WHEN this.SektorFilter != Empty THEN SektorFilter ELSE <Wildcard> END)

Or translated to Obsidian/Dataview something like this using the ‘choice’ function:

Dataview

TABLE WITHOUT ID Sektor, file.link AS "Name"
WHERE Sektor = choice(thos.SektorFilter != Empty, this.SektorFilter, <Wildcard>)
FROM #Quest

Some googling revealed to me that there is no wildchard or similar, so I guess I need a different approach. I also played around with row[…] but didn’t come to any result. Can anybody give me a hint into the right direction?

I’m not entirely sure I understand what you want as output. If the filter is “Sommer”, do you only want those with “Sommer” or do you want to include those not having a defined “Sektor” to? And if the filter is empty, is that all quests, or just those not having a defined “Sektor”?

Depending on your response you could either use or clauses, or possibly the default() function on combination with choice().

If SektorFilter:: Winter i want only those quests:

Sektor Name
Winter Goat_Furr-Quest
Winter Gift_Golden_Dragon-Quest

If SektorFilter:: Empty i want all quests:

Sektor Name
Winter Goat_Furr-Quest
Summer Frohob_Son-Quest
Empty Infernal_Spider-Quest
Winter Gift_Golden_Dragon-Quest

If SektorFilter:: XXX (random filter) i want no quests:

Sektor Name
Empty Empty

The other way around it would be

TABLE WITHOUT ID file.link AS "Name", Sektor
FROM #Quest   
WHERE Sektor = this.SektorFilter OR Sektor = Empty

but that’s exactly what I don’t want :slight_smile:

Why is that last one not what you want?

Or possibly WHERE Sektor = this.SektorFilter or this.SektorFilter = "" ?