The DQL30 does what your original DQL that contains 252 country codes does.
What you have to do is to modify the FROM
statement.
Topic
Summary
- How to transform a country code into a flag emoji via JavaScript Objects?
- How to simplify nested choices where a
Medium
field content is “Book”, “Audiobook”, “Podcast” or “eBook”?
Test
Summary
- dataview: v0.5.46
Input
Summary
dictionary files:
Summary
- Location: “100_Project/02_dataview/Q20_Flags/Q20_test_data04”
folder: 03
- filename :
dic_19800311
(US=United States) (GB=United Kingdom)
---
Date: 1980-03-11
tags: [Favorite]
Alias: "Javascript: The Definitive Guide, 7/e"
Medium: "Book"
Author: "David Flanagan"
Country: "US, GB"
DateStarted: "2020-06-23"
DateFinished: "2020-07-25"
Status: "done"
Year: 2020
Rating: 5
Pages: 680
Hours:
Cover: https://m.media-amazon.com/images/W/WEBP\_402378-T2/images/I/919ZMTHDPBL.\_AC\_SX75\_CR,0,0,75,75\_.jpg
---
# Javascript: The Definitive Guide, 7/e
- What :: [Javascript: The Definitive Guide, 7/e](https://www.amazon.com/-/es/David-Flanagan/dp/1491952024/ref=sr_1_1?__mk_es_US=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=32QHTGRP393RS&keywords=Javascript&qid=1672211738&s=books&sprefix=javascript%2Cstripbooks-intl-ship%2C286&sr=1-1)
- Authors ::
- Keywords ::
- Summaries ::
- Comments ::
- Downloaded ::
folder: 04
- filename :
dic_19800411
(IT=Italy)
---
Date: 1980-04-11
tags: [Favorite]
Alias: "UNIX Shells by Example, 4/e"
Medium: "Audiobook"
Author: "Ellie Quigley"
Country: "IT"
DateStarted: "2004-09-01"
DateFinished: "2005-12-25"
Status: "done"
Year: 2004
Rating: 4
Pages:
Hours: 1200
Cover: https://m.media-amazon.com/images/W/WEBP\_402378-T2/images/I/91vUmLEjbHL.\_AC\_SX75\_CR,0,0,75,75\_.jpg
---
# UNIX Shells by Example, 4/e
- What :: [UNIX Shells by Example, 4/e](https://www.amazon.com/-/es/Ellie-Quigley/dp/013147572X/ref=sr_1_1?__mk_es_US=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=IHF5F5CXXTV0&keywords=UNIX+Shells+by+Example&qid=1672214391&s=books&sprefix=unix+shells+by+example%2Cstripbooks-intl-ship%2C250&sr=1-1)
- Authors ::
- Keywords ::
- Summaries ::
- Comments ::
- Downloaded ::
folder: 05
- filename :
dic_19800511
(DE=Germany)
---
Date: 1980-05-11
tags: [Favorite]
Alias: "P_Podcast"
Medium: "Podcast"
Author: "YYY"
Country: "DE"
DateStarted: "2022-12-16"
DateFinished: "2022-12-17"
Status: "done"
Year: 2000
Rating: 3
Pages:
Hours: 8
Cover: https://media.wnyc.org/i/200/200/c/70/2022/12/NullandVoid_1600x1200.png
---
# Null and Void
- What :: [Null and Void](https://radiolab.org/episodes/null-and-void-2212)
- Authors ::
- Keywords ::
- Summaries ::
- Comments ::
- Downloaded ::
folder: 06
- filename :
dic_19800611
(FR=France)
---
Date: 1980-06-11
tags: [Favorite]
Alias: "Perl by Example, 5/e"
Medium: "eBook"
Author: "Ellie Quigley"
Country: "FR"
DateStarted: "2014-12-17"
DateFinished: "2015-12-21"
Status: "done"
Year: 2014
Rating: 5
Pages: 888
Hours:
Cover: https://m.media-amazon.com/images/W/WEBP\_402378-T2/images/I/41aGGHu7Q-L.\_AC\_SX75\_CR,0,0,75,75\_.jpg
---
# Perl by Example, 5/e
- What :: [Perl by Example, 5/e](https://www.amazon.com/-/es/Ellie-Quigley/dp/0133760812/ref=sr_1_1?__mk_es_US=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=207AKU6YA3671&keywords=perl+by+example&qid=1672212277&s=books&sprefix=perl+by+exampl%2Cstripbooks-intl-ship%2C432&sr=1-1)
- Authors ::
- Keywords ::
- Summaries ::
- Comments ::
- Downloaded ::
folder: 08_excluded
- filename :
dic_19800811
(US=United States)
---
Date: 1980-08-11
tags: [test]
Alias: "Z_Others"
Medium: "Others"
Author: "XXX"
Country: "US"
DateStarted:
DateFinished:
Status: "done"
Year: 2020
Rating: 1
Pages: 100
Hours:
Cover:
---
# Z_Others
- What ::
- Authors ::
- Keywords ::
- Summaries ::
- Comments ::
- Downloaded ::
DQL30_simplify_nested_choices_via_JavaScript_Objects_and_TABLE
Summary
Main DQL
Code Name | Data type | Group By | Purposes | Remark |
---|---|---|---|---|
DQL30 _simplify_nested_choices _via_JavaScript_Objects _and_TABLE |
Country :1.a string like “FR” 2.a tring like “US, GB” Medium :1.“Book” 2.“Audiobook” 3.“Podcast” 4.“eBook” |
no | 1.To simplify ReaderGuy42’s original DQL that contains 252 country codes 2.For best performance 3.For easier reading 4.For easier modification 5.For easier debugging |
For Windows OS (To see Notes of the DQL10 _transform_country_code _into_flag_icon _from_HTML_Hex _and_TABLE): 1.To require NotoColorEmojiLimited.css 2.To enable the CSS snippet |
Notes
Summary
Q1: How to modify the following code when “typeA”, “typeB” or “Others” (icons: a red , yellow or green circle)(units: h, p, p) is added to a Medium field content?
Summary_Q1
Original Example: Q1 (To be modified)
```dataview
WHERE Medium = "Book" OR Medium = "Audiobook" OR Medium = "Podcast" OR Medium = "eBook"
FLATTEN {
"Book": " 📖 ",
"Audiobook": " 🎧 ",
"Podcast": " 📻 ",
"eBook": " 📃 "
}[Medium] AS P_MediumIcon
FLATTEN {
"Book": Pages + " p",
"Audiobook": Hours + " h",
"Podcast": Hours + " h",
"eBook": Pages + " p"
}[Medium] AS Q_PagesHours
```
A1:
Another Example: A1_11
```dataview
WHERE Medium = "Book" OR Medium = "Audiobook" OR Medium = "Podcast" OR Medium = "eBook" OR Medium = "typeA" OR Medium = "typeB" OR Medium = "Others"
FLATTEN {
"Book": " 📖 ",
"Audiobook": " 🎧 ",
"Podcast": " 📻 ",
"eBook": " 📃 ",
"typeA": " 🔴 ",
"typeB": " 🟡 ",
"Others": " 🟢 "
}[Medium] AS P_MediumIcon
FLATTEN {
"Book": Pages + " p",
"Audiobook": Hours + " h",
"Podcast": Hours + " h",
"eBook": Pages + " p",
"typeA": Pages + " h",
"typeB": Pages + " p",
"Others": Pages + " p"
}[Medium] AS Q_PagesHours
```
Code DQL30_simplify_nested_choices_via_JavaScript_Objects_and_TABLE
Summary_code
title: DQL30_simplify_nested_choices_via_JavaScript_Objects_and_TABLE =>0.For Windows OS:To require `NotoColorEmojiLimited.css` and To enable the CSS snippet 1.To simplify ReaderGuy42's original DQL 2.For best performance 3.For easier reading 4.For easier modification 5.For easier debugging
collapse: close
icon:
color:
```dataview
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 AS "Reading Time"
FROM "100_Project/02_dataview/Q20_Flags/Q20_test_data04"
WHERE Status != null
WHERE Medium = "Book" OR Medium = "Audiobook" OR Medium = "Podcast" OR Medium = "eBook"
SORT DateFinished desc
FLATTEN link(file.link, Alias) + " by " + Author AS P_BookByAuthor
FLATTEN choice(contains(tags, "Favorite"), "💛", "") AS P_FavoriteIcon
FLATTEN {
"Book": " 📖 ",
"Audiobook": " 🎧 ",
"Podcast": " 📻 ",
"eBook": " 📃 "
}[Medium] AS P_MediumIcon
FLATTEN DateStarted + " — " + DateFinished AS R_Dates
FLATTEN "(" + choice((DateFinished != DateStarted), (DateFinished - DateStarted).days + " days", "0 days" ) + ")" AS S_ReadingTime
FLATTEN Year + " || " + " ⭐ " + Rating + " || " AS Q_YearRating
FLATTEN {
"Book": Pages + " p",
"Audiobook": Hours + " h",
"Podcast": Hours + " h",
"eBook": Pages + " p"
}[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
```
Screenshots(DQL30): NotoColorEmojiLimited.css
used on win7
Screenshots(DQL30): NotoColorEmojiLimited.css
not used on win7
Related resources
Summary
Emojis
JavaScript Objects
The exercises of using FLATTEN
- Q01_Sum: (Topic : S02) > DQL20_sum_number_or_list_GROUP_BY from 20220725_Solutions
- Q17_Purchases: Solutions
- Q18_QAA: Solutions_S1
- Q19_Workout: Solutions
- Q78_ddMMyyyy: Solutions
- Q79_SumOvertime: Solutions
- Q90_Duration: Solutions
- Q94_Embed: Solutions