Continuing the discussion from Dataview "contains" help:
So I have this Dataview Query for a book gallery:
```dataview
TABLE WITHOUT ID
file.link AS "FILE",
Q_FLAG AS "Q_FLAG"
FROM "100_Project/02_dataview/Q25_MetaFunction/Q25_test_data02"
WHERE Country
FLATTEN join(map(choice(typeof(Country) = "array", Country, list(Country)), (c) => {
BZ: "🇧🇿",
CA: "🇨🇦",
US: "🇺🇸"
}[meta(c).display])) AS Q_FLAG
SORT file.name ASC
and I thought I’d add something so not only the book title, and the author would be clickable (since the author’s are aliased like this in the book note: "[[King, Stephen|Stephen King]]"
), but also the Flag would be clickable, by changing it like so:
TABLE WITHOUT ID
file.link AS "FILE",
Q_Country AS "FLAG" <------------------
FROM "100_Project/02_dataview/Q25_MetaFunction/Q25_test_data02"
WHERE Country
FLATTEN join(map(choice(typeof(Country) = "array", Country, list(Country)), (c) => {
BZ: "🇧🇿",
CA: "🇨🇦",
US: "🇺🇸"
}[meta(c).display])) AS Q_FLAG
FLATTEN link(Country, Q_FLAG) AS Q_Country <----------------------
SORT file.name ASC
This actually works! However, sometimes there are books that have two countries, making the Country:
key look like this:
Country:
- "[[United Kingdom|GB]]"
- "[[United States|US]]"
This causes TWO cards to be created, one with a link to United Kingdom, one to US:
The links are clickable. But I’d prefer it if the links were clickable only within the respective flag emoji, and there only to be one Card if I’ve only read the book once.
Is this possible?
Thanks!
EDIT: Replacing Country
with list(Country)
in the last bit, solves one problem but causes another. Now the last line looks like this:
FLATTEN link(list(Country), Q_FLAG) AS Q_Country
this prevents TWO Cards being created, but now the two flags are doubled, one with a link to the UK one to US:
One step forward, one sideways, I guess haha