Dataview "contains" help

Ah OK, that makes sense :slight_smile: Thank you!!

Just in case anyoneโ€™s interested, Iโ€™ve now implemented that into my crazy query:

TABLE without id 
      ("![](" + Cover + ")") AS "Cover",
      P_BookByAuthor + P_MediumIcon + P_FavoriteIcon AS "Title",
      Q_YearRating + Q_PagesHours + " || " + Q_FLAG AS "Time and Place",      
      R_Dates AS "Dates",
      "(" + S_ReadingTime + " || " + S_ReadingSpeed + ")" AS "Reading Time"
      
FROM "Book Log" OR "Y Movies and Games" OR "0 Currently Reading" OR "Set Aside"

FLATTEN {
    "Book": Author,
    "Audiobook": Author,
    "Podcast": Author,
    "eBook": Author,
    "AcademicBook": Author,
    "AcademicArticle": Author,
    "GraphicNovel": Author,
    "Movie": Director,
    "TV": Director,
    "Game": Director
}[Medium] AS OneAuthor
WHERE econtains(meta(OneAuthor).path, this.file.path)
SORT DateFinished asc


FLATTEN link(file.link, Alias) + " by " + OneAuthor AS P_BookByAuthor
FLATTEN choice(contains(tags, "Favorite"), "๐Ÿ’›", "") AS P_FavoriteIcon

FLATTEN {
    "Book": " ๐Ÿ“– ",
    "Audiobook": " ๐ŸŽง ",
    "Podcast": " ๐Ÿ“ป ",
    "eBook": " ๐Ÿ“ƒ ",
    "AcademicBook": " ๐Ÿ“š๐ŸŽ“ ",
    "AcademicArticle": " ๐Ÿ“ฐ ",
    "GraphicNovel": " ๐Ÿ’ฌ ",
	"Movie": " ๐ŸŽž๏ธ ",
	"TV": " ๐Ÿ“บ ",
	"Game": " ๐ŸŽฎ "
}[Medium] AS P_MediumIcon



FLATTEN DateStarted + " โ€” " + DateFinished AS R_Dates

FLATTEN choice(((DateFinished - DateStarted).days = 1), "1 day",  choice((DateFinished != DateStarted), (DateFinished - DateStarted).days + " days", "0 days" )) AS S_ReadingTime


FLATTEN {
"Book": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"Audiobook": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 2) + " h/d",
"Podcast": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 2)+ " h/d",
"eBook": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"GraphicNovel": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"AcademicBook": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"AcademicArticle": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"Movie": round(choice((DateFinished = DateStarted), round((Length/60), 1), (Length / (DateFinished - DateStarted).days)), 1) + " h/d",
"TV": round(choice((DateFinished = DateStarted), round((Length/60), 1), (Length / (DateFinished - DateStarted).days)), 1) + " h/d",
"Game": round(choice((DateFinished = DateStarted), round((Length/60), 1), (Length / (DateFinished - DateStarted).days)), 1) + " h/d"
}[Medium] AS S_ReadingSpeed


FLATTEN Year + " || " + " โญ " + Rating + " || " AS Q_YearRating

FLATTEN {
    "Book": Length + " p",
    "Audiobook": Length + " h",
    "Podcast": Length + " h",
    "eBook": Length + " p",
    "GraphicNovel": Length + " p",
    "AcademicBook": Length + " p",
    "AcademicArticle": Length + " p",
	"Movie": round((Length/60), 1) + " h",
	"TV": round((Length/60), 1) + " h",
	"Game": round((Length/60), 1) + " h"
}[Medium] AS Q_PagesHours


FLATTEN join(map(split(Country, ", "), (c) => {
AD: "๐Ÿ‡ฆ๐Ÿ‡ฉ",
AE: "๐Ÿ‡ฆ๐Ÿ‡ช",
AF: "๐Ÿ‡ฆ๐Ÿ‡ซ",
AG: "๐Ÿ‡ฆ๐Ÿ‡ฌ",
AI: "๐Ÿ‡ฆ๐Ÿ‡ฎ",
AL: "๐Ÿ‡ฆ๐Ÿ‡ฑ",
AM: "๐Ÿ‡ฆ๐Ÿ‡ฒ",
AO: "๐Ÿ‡ฆ๐Ÿ‡ด",
AQ: "๐Ÿ‡ฆ๐Ÿ‡ถ",
AR: "๐Ÿ‡ฆ๐Ÿ‡ท",
AS: "๐Ÿ‡ฆ๐Ÿ‡ธ",
AT: "๐Ÿ‡ฆ๐Ÿ‡น",
AU: "๐Ÿ‡ฆ๐Ÿ‡บ",
AW: "๐Ÿ‡ฆ๐Ÿ‡ผ",
AX: "๐Ÿ‡ฆ๐Ÿ‡ฝ",
AZ: "๐Ÿ‡ฆ๐Ÿ‡ฟ",
BA: "๐Ÿ‡ง๐Ÿ‡ฆ",
BB: "๐Ÿ‡ง๐Ÿ‡ง",
BD: "๐Ÿ‡ง๐Ÿ‡ฉ",
BE: "๐Ÿ‡ง๐Ÿ‡ช",
BF: "๐Ÿ‡ง๐Ÿ‡ซ",
BG: "๐Ÿ‡ง๐Ÿ‡ฌ",
BH: "๐Ÿ‡ง๐Ÿ‡ญ",
BI: "๐Ÿ‡ง๐Ÿ‡ฎ",
BJ: "๐Ÿ‡ง๐Ÿ‡ฏ",
BL: "๐Ÿ‡ง๐Ÿ‡ฑ",
BM: "๐Ÿ‡ง๐Ÿ‡ฒ",
BN: "๐Ÿ‡ง๐Ÿ‡ณ",
BO: "๐Ÿ‡ง๐Ÿ‡ด",
BQ: "๐Ÿ‡ง๐Ÿ‡ถ",
BR: "๐Ÿ‡ง๐Ÿ‡ท",
BS: "๐Ÿ‡ง๐Ÿ‡ธ",
BT: "๐Ÿ‡ง๐Ÿ‡น",
BV: "๐Ÿ‡ง๐Ÿ‡ป",
BW: "๐Ÿ‡ง๐Ÿ‡ผ",
BY: "๐Ÿ‡ง๐Ÿ‡พ",
BZ: "๐Ÿ‡ง๐Ÿ‡ฟ",
CA: "๐Ÿ‡จ๐Ÿ‡ฆ",
CC: "๐Ÿ‡จ๐Ÿ‡จ",
CD: "๐Ÿ‡จ๐Ÿ‡ฉ",
CF: "๐Ÿ‡จ๐Ÿ‡ซ",
CG: "๐Ÿ‡จ๐Ÿ‡ฌ",
CH: "๐Ÿ‡จ๐Ÿ‡ญ",
CI: "๐Ÿ‡จ๐Ÿ‡ฎ",
CK: "๐Ÿ‡จ๐Ÿ‡ฐ",
CL: "๐Ÿ‡จ๐Ÿ‡ฑ",
CM: "๐Ÿ‡จ๐Ÿ‡ฒ",
CN: "๐Ÿ‡จ๐Ÿ‡ณ",
CO: "๐Ÿ‡จ๐Ÿ‡ด",
CR: "๐Ÿ‡จ๐Ÿ‡ท",
CU: "๐Ÿ‡จ๐Ÿ‡บ",
CV: "๐Ÿ‡จ๐Ÿ‡ป",
CW: "๐Ÿ‡จ๐Ÿ‡ผ",
CX: "๐Ÿ‡จ๐Ÿ‡ฝ",
CY: "๐Ÿ‡จ๐Ÿ‡พ",
CYMRU: "๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ",
CZ: "๐Ÿ‡จ๐Ÿ‡ฟ",
DE: "๐Ÿ‡ฉ๐Ÿ‡ช",
DJ: "๐Ÿ‡ฉ๐Ÿ‡ฏ",
DK: "๐Ÿ‡ฉ๐Ÿ‡ฐ",
DM: "๐Ÿ‡ฉ๐Ÿ‡ฒ",
DO: "๐Ÿ‡ฉ๐Ÿ‡ด",
DZ: "๐Ÿ‡ฉ๐Ÿ‡ฟ",
EC: "๐Ÿ‡ช๐Ÿ‡จ",
EE: "๐Ÿ‡ช๐Ÿ‡ช",
EG: "๐Ÿ‡ช๐Ÿ‡ฌ",
EH: "๐Ÿ‡ช๐Ÿ‡ญ",
ENG: "๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ",
ER: "๐Ÿ‡ช๐Ÿ‡ท",
ES: "๐Ÿ‡ช๐Ÿ‡ธ",
ET: "๐Ÿ‡ช๐Ÿ‡น",
FI: "๐Ÿ‡ซ๐Ÿ‡ฎ",
FJ: "๐Ÿ‡ซ๐Ÿ‡ฏ",
FK: "๐Ÿ‡ซ๐Ÿ‡ฐ",
FM: "๐Ÿ‡ซ๐Ÿ‡ฒ",
FO: "๐Ÿ‡ซ๐Ÿ‡ด",
FR: "๐Ÿ‡ซ๐Ÿ‡ท",
GA: "๐Ÿ‡ฌ๐Ÿ‡ฆ",
GB: "๐Ÿ‡ฌ๐Ÿ‡ง",
GD: "๐Ÿ‡ฌ๐Ÿ‡ฉ",
GE: "๐Ÿ‡ฌ๐Ÿ‡ช",
GF: "๐Ÿ‡ฌ๐Ÿ‡ซ",
GG: "๐Ÿ‡ฌ๐Ÿ‡ฌ",
GH: "๐Ÿ‡ฌ๐Ÿ‡ญ",
GI: "๐Ÿ‡ฌ๐Ÿ‡ฎ",
GL: "๐Ÿ‡ฌ๐Ÿ‡ฑ",
GM: "๐Ÿ‡ฌ๐Ÿ‡ฒ",
GN: "๐Ÿ‡ฌ๐Ÿ‡ณ",
GP: "๐Ÿ‡ฌ๐Ÿ‡ต",
GQ: "๐Ÿ‡ฌ๐Ÿ‡ถ",
GR: "๐Ÿ‡ฌ๐Ÿ‡ท",
GS: "๐Ÿ‡ฌ๐Ÿ‡ธ",
GT: "๐Ÿ‡ฌ๐Ÿ‡น",
GU: "๐Ÿ‡ฌ๐Ÿ‡บ",
GW: "๐Ÿ‡ฌ๐Ÿ‡ผ",
GY: "๐Ÿ‡ฌ๐Ÿ‡พ",
HK: "๐Ÿ‡ญ๐Ÿ‡ฐ",
HM: "๐Ÿ‡ญ๐Ÿ‡ฒ",
HN: "๐Ÿ‡ญ๐Ÿ‡ณ",
HR: "๐Ÿ‡ญ๐Ÿ‡ท",
HT: "๐Ÿ‡ญ๐Ÿ‡น",
HU: "๐Ÿ‡ญ๐Ÿ‡บ",
ID: "๐Ÿ‡ฎ๐Ÿ‡ฉ",
IE: "๐Ÿ‡ฎ๐Ÿ‡ช",
IL: "๐Ÿ‡ฎ๐Ÿ‡ฑ",
IM: "๐Ÿ‡ฎ๐Ÿ‡ฒ",
IN: "๐Ÿ‡ฎ๐Ÿ‡ณ",
IO: "๐Ÿ‡ฎ๐Ÿ‡ด",
IQ: "๐Ÿ‡ฎ๐Ÿ‡ถ",
IR: "๐Ÿ‡ฎ๐Ÿ‡ท",
IS: "๐Ÿ‡ฎ๐Ÿ‡ธ",
IT: "๐Ÿ‡ฎ๐Ÿ‡น",
JE: "๐Ÿ‡ฏ๐Ÿ‡ช",
JM: "๐Ÿ‡ฏ๐Ÿ‡ฒ",
JO: "๐Ÿ‡ฏ๐Ÿ‡ด",
JP: "๐Ÿ‡ฏ๐Ÿ‡ต",
KE: "๐Ÿ‡ฐ๐Ÿ‡ช",
KG: "๐Ÿ‡ฐ๐Ÿ‡ฌ",
KH: "๐Ÿ‡ฐ๐Ÿ‡ญ",
KI: "๐Ÿ‡ฐ๐Ÿ‡ฎ",
KM: "๐Ÿ‡ฐ๐Ÿ‡ฒ",
KN: "๐Ÿ‡ฐ๐Ÿ‡ณ",
KP: "๐Ÿ‡ฐ๐Ÿ‡ต",
KR: "๐Ÿ‡ฐ๐Ÿ‡ท",
KW: "๐Ÿ‡ฐ๐Ÿ‡ผ",
KY: "๐Ÿ‡ฐ๐Ÿ‡พ",
KZ: "๐Ÿ‡ฐ๐Ÿ‡ฟ",
LA: "๐Ÿ‡ฑ๐Ÿ‡ฆ",
LB: "๐Ÿ‡ฑ๐Ÿ‡ง",
LC: "๐Ÿ‡ฑ๐Ÿ‡จ",
LI: "๐Ÿ‡ฑ๐Ÿ‡ฎ",
LK: "๐Ÿ‡ฑ๐Ÿ‡ฐ",
LR: "๐Ÿ‡ฑ๐Ÿ‡ท",
LS: "๐Ÿ‡ฑ๐Ÿ‡ธ",
LT: "๐Ÿ‡ฑ๐Ÿ‡น",
LU: "๐Ÿ‡ฑ๐Ÿ‡บ",
LV: "๐Ÿ‡ฑ๐Ÿ‡ป",
LY: "๐Ÿ‡ฑ๐Ÿ‡พ",
MA: "๐Ÿ‡ฒ๐Ÿ‡ฆ",
MC: "๐Ÿ‡ฒ๐Ÿ‡จ",
MD: "๐Ÿ‡ฒ๐Ÿ‡ฉ",
ME: "๐Ÿ‡ฒ๐Ÿ‡ช",
MF: "๐Ÿ‡ฒ๐Ÿ‡ซ",
MG: "๐Ÿ‡ฒ๐Ÿ‡ฌ",
MH: "๐Ÿ‡ฒ๐Ÿ‡ญ",
MK: "๐Ÿ‡ฒ๐Ÿ‡ฐ",
ML: "๐Ÿ‡ฒ๐Ÿ‡ฑ",
MM: "๐Ÿ‡ฒ๐Ÿ‡ฒ",
MN: "๐Ÿ‡ฒ๐Ÿ‡ณ",
MO: "๐Ÿ‡ฒ๐Ÿ‡ด",
MP: "๐Ÿ‡ฒ๐Ÿ‡ต",
MQ: "๐Ÿ‡ฒ๐Ÿ‡ถ",
MR: "๐Ÿ‡ฒ๐Ÿ‡ท",
MS: "๐Ÿ‡ฒ๐Ÿ‡ธ",
MT: "๐Ÿ‡ฒ๐Ÿ‡น",
MU: "๐Ÿ‡ฒ๐Ÿ‡บ",
MV: "๐Ÿ‡ฒ๐Ÿ‡ป",
MW: "๐Ÿ‡ฒ๐Ÿ‡ผ",
MX: "๐Ÿ‡ฒ๐Ÿ‡ฝ",
MY: "๐Ÿ‡ฒ๐Ÿ‡พ",
MZ: "๐Ÿ‡ฒ๐Ÿ‡ฟ",
NA: "๐Ÿ‡ณ๐Ÿ‡ฆ",
NC: "๐Ÿ‡ณ๐Ÿ‡จ",
NE: "๐Ÿ‡ณ๐Ÿ‡ช",
NF: "๐Ÿ‡ณ๐Ÿ‡ซ",
NG: "๐Ÿ‡ณ๐Ÿ‡ฌ",
NI: "๐Ÿ‡ณ๐Ÿ‡ฎ",
NL: "๐Ÿ‡ณ๐Ÿ‡ฑ",
NO: "๐Ÿ‡ณ๐Ÿ‡ด",
NP: "๐Ÿ‡ณ๐Ÿ‡ต",
NR: "๐Ÿ‡ณ๐Ÿ‡ท",
NU: "๐Ÿ‡ณ๐Ÿ‡บ",
NZ: "๐Ÿ‡ณ๐Ÿ‡ฟ",
OM: "๐Ÿ‡ด๐Ÿ‡ฒ",
PA: "๐Ÿ‡ต๐Ÿ‡ฆ",
PE: "๐Ÿ‡ต๐Ÿ‡ช",
PF: "๐Ÿ‡ต๐Ÿ‡ซ",
PG: "๐Ÿ‡ต๐Ÿ‡ฌ",
PH: "๐Ÿ‡ต๐Ÿ‡ญ",
PK: "๐Ÿ‡ต๐Ÿ‡ฐ",
PL: "๐Ÿ‡ต๐Ÿ‡ฑ",
PM: "๐Ÿ‡ต๐Ÿ‡ฒ",
PN: "๐Ÿ‡ต๐Ÿ‡ณ",
PR: "๐Ÿ‡ต๐Ÿ‡ท",
PS: "๐Ÿ‡ต๐Ÿ‡ธ",
PT: "๐Ÿ‡ต๐Ÿ‡น",
PW: "๐Ÿ‡ต๐Ÿ‡ผ",
PY: "๐Ÿ‡ต๐Ÿ‡พ",
QA: "๐Ÿ‡ถ๐Ÿ‡ฆ",
RE: "๐Ÿ‡ท๐Ÿ‡ช",
RO: "๐Ÿ‡ท๐Ÿ‡ด",
RS: "๐Ÿ‡ท๐Ÿ‡ธ",
RU: "๐Ÿ‡ท๐Ÿ‡บ",
RW: "๐Ÿ‡ท๐Ÿ‡ผ",
SA: "๐Ÿ‡ธ๐Ÿ‡ฆ",
SB: "๐Ÿ‡ธ๐Ÿ‡ง",
SC: "๐Ÿ‡ธ๐Ÿ‡จ",
SCOT: "๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ",
SD: "๐Ÿ‡ธ๐Ÿ‡ฉ",
SE: "๐Ÿ‡ธ๐Ÿ‡ช",
SG: "๐Ÿ‡ธ๐Ÿ‡ฌ",
SH: "๐Ÿ‡ธ๐Ÿ‡ญ",
SI: "๐Ÿ‡ธ๐Ÿ‡ฎ",
SJ: "๐Ÿ‡ธ๐Ÿ‡ฏ",
SK: "๐Ÿ‡ธ๐Ÿ‡ฐ",
SL: "๐Ÿ‡ธ๐Ÿ‡ฑ",
SM: "๐Ÿ‡ธ๐Ÿ‡ฒ",
SN: "๐Ÿ‡ธ๐Ÿ‡ณ",
SO: "๐Ÿ‡ธ๐Ÿ‡ด",
SR: "๐Ÿ‡ธ๐Ÿ‡ท",
SS: "๐Ÿ‡ธ๐Ÿ‡ธ",
ST: "๐Ÿ‡ธ๐Ÿ‡น",
SV: "๐Ÿ‡ธ๐Ÿ‡ป",
SX: "๐Ÿ‡ธ๐Ÿ‡ฝ",
SY: "๐Ÿ‡ธ๐Ÿ‡พ",
SZ: "๐Ÿ‡ธ๐Ÿ‡ฟ",
TC: "๐Ÿ‡น๐Ÿ‡จ",
TD: "๐Ÿ‡น๐Ÿ‡ฉ",
TF: "๐Ÿ‡น๐Ÿ‡ซ",
TG: "๐Ÿ‡น๐Ÿ‡ฌ",
TH: "๐Ÿ‡น๐Ÿ‡ญ",
TJ: "๐Ÿ‡น๐Ÿ‡ฏ",
TK: "๐Ÿ‡น๐Ÿ‡ฐ",
TL: "๐Ÿ‡น๐Ÿ‡ฑ",
TM: "๐Ÿ‡น๐Ÿ‡ฒ",
TN: "๐Ÿ‡น๐Ÿ‡ณ",
TO: "๐Ÿ‡น๐Ÿ‡ด",
TR: "๐Ÿ‡น๐Ÿ‡ท",
TT: "๐Ÿ‡น๐Ÿ‡น",
TV: "๐Ÿ‡น๐Ÿ‡ป",
TW: "๐Ÿ‡น๐Ÿ‡ผ",
TZ: "๐Ÿ‡น๐Ÿ‡ฟ",
UA: "๐Ÿ‡บ๐Ÿ‡ฆ",
UG: "๐Ÿ‡บ๐Ÿ‡ฌ",
UM: "๐Ÿ‡บ๐Ÿ‡ฒ",
US: "๐Ÿ‡บ๐Ÿ‡ธ",
UY: "๐Ÿ‡บ๐Ÿ‡พ",
UZ: "๐Ÿ‡บ๐Ÿ‡ฟ",
VA: "๐Ÿ‡ป๐Ÿ‡ฆ",
VC: "๐Ÿ‡ป๐Ÿ‡จ",
VE: "๐Ÿ‡ป๐Ÿ‡ช",
VG: "๐Ÿ‡ป๐Ÿ‡ฌ",
VI: "๐Ÿ‡ป๐Ÿ‡ฎ",
VN: "๐Ÿ‡ป๐Ÿ‡ณ",
VU: "๐Ÿ‡ป๐Ÿ‡บ",
WF: "๐Ÿ‡ผ๐Ÿ‡ซ",
WS: "๐Ÿ‡ผ๐Ÿ‡ธ",
YE: "๐Ÿ‡พ๐Ÿ‡ช",
YT: "๐Ÿ‡พ๐Ÿ‡น",
ZA: "๐Ÿ‡ฟ๐Ÿ‡ฆ",
ZM: "๐Ÿ‡ฟ๐Ÿ‡ฒ",
ZW: "๐Ÿ‡ฟ๐Ÿ‡ผ"
}[c])) AS Q_FLAG

1 Like

That is indeed a crazy query. Could you also show how it actually looks, or the top of a result from it?

Did you get that other post regarding how the subtraction of dates could be a little off when the days exceeded over a month? Shouldnโ€™t matter a whole lot, but I just thought Iโ€™d mention it.

I didnโ€™t see that other post, but honestly the dates are just for estimates. Not doing science here haha

Combined with Cards, this is a sample of my gallery:

I just finished aliasing all authors and movie directors, so now all book/movie titles and all authors/directors are clickable.

3 Likes

Related to this, I tried doing the same aliasing to my two-letter country code, e.g. Country: US to Country: "[[United States of America|US]]"
so I can also have a list by country page.

However, your awesome solution to my earlier problem from a few months ago, now no longer works, meaning I broke my query again:

FLATTEN join(map(split(Country, ", "), (c) => {
BZ: "๐Ÿ‡ง๐Ÿ‡ฟ",
CA: "๐Ÿ‡จ๐Ÿ‡ฆ",
US: "๐Ÿ‡บ๐Ÿ‡ธ"

}[c])) AS Q_FLAG

I canโ€™t figure out how to implement this with the aliasing, since I now separate the Countries like this:

Country: 
- "[[United States of America|US]]"
- "[[Canada|CA]]"

instead of like previously with a comma. The split command no longer works, since thereโ€™s no longer a split by commas, but removing the split thing doesnโ€™t solve the problem.

Something like this also doesnโ€™t work:

FLATTEN Country {
BZ: "๐Ÿ‡ง๐Ÿ‡ฟ",
CA: "๐Ÿ‡จ๐Ÿ‡ฆ",
US: "๐Ÿ‡บ๐Ÿ‡ธ"

} AS Q_FLAG

Can this be fixed? Thanks!

Topic

Summary
  • How to to transform a country code into a flag icon via a JavaScript object?

Test

Summary
  • dataview: v0.5.55

Input

Summary

dictionary files:

Summary
  • Location: โ€œ100_Project/02_dataview/Q25_MetaFunction/Q25_test_data02โ€

folder: 03_a_string

  • filename : dic_19620306
---
Date: 1962-03-06
Country: "[[Canada|CA]]"
---


folder: 04_a_list

  • filename : dic_19800401
---
Date: 1962-04-06
Country: 
- "[[United States of America|US]]"
---


folder: 05_a_list

  • filename : dic_19800501
---
Date: 1962-05-06
Country: 
- "[[United States of America|US]]"
- "[[Canada|CA]]"
---


DQL11_transform_country_code_into_flag_icon_via_JavaScript_object_and_TABLE

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL11
_transform_country_code
_into_flag_icon
_via_JavaScript_object
_and_TABLE
Country:
1.a string like
โ€œ[[Canada|CA]]โ€
2.an array of strings like
[โ€œ[[United States of America|US]]โ€]

no 1.To filter by Country
2.To transform a country code into a flag icon via a JavaScript object
3.To sort by file.name in ascending order
4.To display the result as a table
For Windows OS
(To see Notes of the DQL10
_transform_country_code
_into_flag_icon
_from_HTML_Hex
_and_TABLE):
from Q20_Flags: S1

1.To require NotoColorEmojiLimited.css
2.To enable the CSS snippet

Notes:

Summary

Q1: How to modify the following code?

Summary_Q1
Original Example: Q1 (To be modified and explained)
Original INPUT
  • filename : O1
---
Country: "US"
---

  • filename : O2
---
Country: "US, CA"
---

Original DQL
```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


// The input of map() method is an Array of Strings in the example.
// AoS is an abbreviation for an Array of Strings.
// O1: AoS = split(Country, ", ") = ["US"];
// O2: AoS = split(Country, ", ") = ["US", "CA"];
// c = an element of AoS;
// O1: c = "US";
// O2: c = "US", or "CA";
FLATTEN join(map(split(Country, ", "), (c) => {
BZ: "๐Ÿ‡ง๐Ÿ‡ฟ",
CA: "๐Ÿ‡จ๐Ÿ‡ฆ",
US: "๐Ÿ‡บ๐Ÿ‡ธ"

}[c])) AS Q_FLAG

```

A1_11:

Another Example: A1_11
New INPUT
  • filename : N1
---
Country: "[[United States of America|US]]"
---

  • filename : N2
---
Country: 
- "[[United States of America|US]]"
- "[[Canada|CA]]"
---

New DQL
```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


// The input of map() method is an Array of Strings in the example.
// AoS is an abbreviation for an Array of Strings.
// N1: AoS = list(Country) = ["[[United States of America|US]]"];
// N2: AoS = Country = ["[[United States of America|US]]", "[[Canada|CA]]"];
// c = an element of AoS;
// N1: meta(c).display = "US";
// N2: meta(c).display = "US", or "CA";
FLATTEN join(map(choice(typeof(Country) = "array", Country, list(Country)), (c) => {
BZ: "๐Ÿ‡ง๐Ÿ‡ฟ",
CA: "๐Ÿ‡จ๐Ÿ‡ฆ",
US: "๐Ÿ‡บ๐Ÿ‡ธ"

}[meta(c).display])) AS Q_FLAG

```

Code DQL11_transform_country_code_into_flag_icon_via_JavaScript_object_and_TABLE

Summary_code
title: DQL11_transform_country_code_into_flag_icon_via_JavaScript_object_and_TABLE =>0.For Windows OS:To require `NotoColorEmojiLimited.css` and To enable the CSS snippet 1.To filter by `Country` 2.To transform a country code into a flag icon via a JavaScript object 3.To sort by `file.name` in ascending order 4.To display the result as a table
collapse: close
icon: 
color: 
```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

```

Screenshots(DQL10): NotoColorEmojiLimited.css used on win7

Summary_A


Screenshots(DQL10): NotoColorEmojiLimited.css not used on win7

Summary_B


Reference

Summary

Q20_Flags


2 Likes

Perfect, thank you!!!

1 Like

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