Summary
Q: How to gather list items or task items under the specific heading?
- How to gather list items where the heading contains “milestones”? (
DQL01
)
- How to gather task items where the heading contains “tasks”? (
DQL03
)
- How to gather list items where the heading contains “milestones” and to gather task items where the heading contains “tasks”? (
DQL05
)
- How to gather list items where the heading contains “milestones” and to gather task items where the heading contains “tasks” and to groupBy file.link? (
DQL07
)
Q: How to distinguish list items from task items from the file.lists data?
Answers
- a list item: !L.task
- a task item: L.task
- L : each element of file.lists of each page
- No one can distinguish a list item from a task item from the value of L.text where L is an element of file.lists .
Q: How to display task items with the checkbox from non-groupBy data by using DQL?
Answers
- Use DQL
TABLE
- L : each element of file.lists of each page
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks"
Q: How to display task items with the checkbox from groupBy data by using DQL?
- Use DQL
TABLE
- L : each element of file.lists of each page;
TABLE WITHOUT ID
map(rows.L, (L) => choice(L.task, "- [" + L.status + "] " + L.text, L.text)) AS "milestones_or_tasks"
Q: How to use FROM source
for best performance when using DQL?
- For best performance, it is recommended that each note is a desired note after using the
FROM source
because dataview will gather list items or task items into the file.lists data of each note which is FROM source
.
- The DQL expression like
FROM source
is equal to the DVJS expression like let pages = dv.pages(source);
- It gathers the following data.
- The
pages
array consists of each page
hash.
- The plain
page
hash from a file is created by the dv.pages(source)
function and consists of three hashes : the page.file
hash, the YAML fields and the Dataview inline fields.
- The YAML fields is also stored in the page.file.frontmatter hash.
- Besides, the key/pair, the page.file.lists and its values, is an element of each
page
hash.
to modify(M1)
Original Example01: use Folders
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
Original Example02: use Folders and Tags
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data" AND #Project
Original Example03: use Tags
FROM #Project
Original Example04 : Single Files
- Inline DQL: To get file.path
path==[[dic_20060301]].file.path
//=>“100_Project/02_dataview/Q93_Tasks/Q93_test_data/03/dic_20060301.md”
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data/03/dic_20060301.md"
Wrong Examples :
- Performance issues :
- The following expression means that
let pages = dv.pages();
- It will gather list items or task items into the page.file.lists of each note but many of them are not necessary.
FROM ""
or
FROM "/"
Q: What does the following DQL statement mean?
FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
Answers
Q: How to use F_subpath
to filter by the specific heading when using DQL?
Case_01:
---
Date: 2006-07-01
---
#Project/P07
Areas:: #research
## input
### ?what: milestones, tasks!
- 2006-07-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-07-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_01
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Case_02:
---
Date: 2006-08-01
---
#Project/P08
Areas:: #research
## input
### what: milestones, tasks!
- 2006-08-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-08-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_02
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Case_03:
---
Date: 2006-09-01
---
#Project/P09
Areas:: #research
## input
### what milestones tasks:
- 2006-09-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-09-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_03
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Case_04:
---
Date: 2006-10-01
---
#Project/P10
Areas:: #research
## input
### what milestones tasks
- 2006-10-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- [ ] 2012-10-11 add this feature_A #Test/d01 [[Note P]] , [[Note Q]]
Answers: Case_04
WHERE contains(F_subpath, "what milestones tasks") AND F_type = "header"
or
WHERE F_subpath = "what milestones tasks" AND F_type = "header"
Q: How to sort the task items which are classified as “T01”, “T02”, “T03” and “T99”?
- How to use nested
choice
?
- How to define a field variable
F_prefix_text
as the expression like choice...
by using FLATTEN
?
Answers
TABLE WITHOUT ID
choice(L.task, "- [" + L.status + "] " + L.text, "- " + L.text) AS "milestones_or_tasks"
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
FLATTEN file.lists AS L
FLATTEN choice(contains(L.text, "✉️") OR (L.status = ">"),
"T01" + L.text,
choice(contains(L.text, "❗") OR (L.status = "!"),
"T02" + L.text,
choice(contains(L.text, "📐"), "T03" + L.text, "T99" + L.text))
) AS F_prefix_text
WHERE L.task and !L.completed
WHERE startswith(F_prefix_text, "T01") OR
startswith(F_prefix_text, "T02") OR
startswith(F_prefix_text, "T03")
SORT F_prefix_text ASC
Summary
Main DQL
Code Name |
Data type |
Group By |
Purposes |
Remark |
DQL20_use_fTasks _and_display_uncompleted_tasks |
flattened file.tasks |
no |
1.To filter by a task 2.To filter by a uncompleted task 3.To filter by F_prefix_text where it starts with “T01” or “T02” or “T03” 4.To sort by F_prefix_text in ascending order 5.To display the result as a taskList [with the desired structure] |
|
Notes
Summary
Q: What does the following DQL statement mean?
WHERE !completed
FLATTEN choice(contains(text, "✉️") OR (status = ">"),
"T01" + text,
choice(contains(text, "❗") OR (status = "!"),
"T02" + text,
choice(contains(text, "📐"), "T03" + text, "T99" + text))
) AS F_prefix_text
SORT F_prefix_text ASC
A1: In English
For each uncompleted task :
case_T01: If contains(text, “
”) OR (status = “>”), let F_prefix_text = “T01” + text;
case_T02: If contains(text, “
”) OR (status = “!”), let F_prefix_text = “T02” + text;
case_T03: If contains(text, “
”), let F_prefix_text = “T03” + text;
case_T99: Otherwise, let F_prefix_text = “T99” + text;
Sort it by the F_prefix_text
in ascending order
After sorting it by the F_prefix_text
in ascending order :
- Each task of case_T01 is in front of each task of case_T02 because “T01” is in front of “T02”.
- “T01” is the prefix of each
F_prefix_text
of case_T01
- “T02” is the prefix of each
F_prefix_text
of case_T02
- Each task of case_T02 is in front of each task of case_T03 because “T02” is in front of “T03”.
- “T02” is the prefix of each
F_prefix_text
of case_T02
- “T03” is the prefix of each
F_prefix_text
of case_T03
A2: Screenshots(DQL20_notes)
case_T01
case_T02
case_T03
case_T01 or case_T02 or case_T03
Sort it by the F_prefix_text
in ascending order
Code DQL20_use_fTasks_and_display_uncompleted_tasks
Summary_code
title: DQL20_use_fTasks_and_display_uncompleted_tasks =>1.To filter by a task 2.To filter by a uncompleted task 3.To filter by F_prefix_text where it starts with "T01" or "T02" or "T03" 4.To sort by F_prefix_text in ascending order 5.To display the result as a taskList [with the desired structure]
collapse: close
icon:
color:
```dataview
TASK
FROM "100_Project/02_dataview/Q93_Tasks/Q93_test_data"
WHERE !completed
FLATTEN choice(contains(text, "✉️") OR (status = ">"),
"T01" + text,
choice(contains(text, "❗") OR (status = "!"),
"T02" + text,
choice(contains(text, "📐"), "T03" + text, "T99" + text))
) AS F_prefix_text
WHERE startswith(F_prefix_text, "T01") OR
startswith(F_prefix_text, "T02") OR
startswith(F_prefix_text, "T03")
SORT F_prefix_text ASC
```
Screenshots(DQL20)