Summarize Daily Notes Using Dataview

Haha, one last question:
The result of the dataviewjs query is not sorted yet. Is ist possible to sort the result chronologically, corresponding to the filenames of my daily notes, which have the format YYYY-MM-DD?
The sorting hierarchy should be from new to old (up to down of the note).

Thanks! :slight_smile:

Dataview can sort for you:

const pages = dv.pages().sort(x => x.file.name, 'desc')

Wow, very, very nice, thanks! :slight_smile:

Okay, and now, the very last question (promise! :slight_smile: ):
image

As you can see, I don’t have entries underneath the “what happened today”-header in every daily note. For example on 2022-08-28 I don’t have an entry. Is it possible to sort these daily notes out of the query, which don’t have an entry underneath the “what happened today”-header?

Change the end to be:

if (summary && summary[1].trim()) {

instead of

if (summary) {

Can I recommend that you have a look at a beginners Javascript course. There’s an amazing German instructor who I love, and this is where I learned Javascript:

https://www.udemy.com/course/javascript-the-complete-guide-2020-beginner-advanced/

It’s very easy, and it will open up a world of possibilities for you in Obsidian and so many other applications.

2 Likes

Hey Alan,
thank you so much for your help, and also for that valuable recommendation! I consider that severly! :slight_smile:

Topic: The file.lists by example (PART I/2)

  • The file.lists by example - Chapter 3: using DQL to gather list items or task items under the specific heading (and filter by a field) (and sum up a field) (and display each DVIF)
Summary
  • How to gather list items or task items under the specific heading? (DQL90 , DVJS90)
  • How to gather list items or task items under the specific heading
    • Each of the following DQLs requires a specific note.
    • How to filter by a field? (DQL10, DQL20, DQL30)
    • How to sum up a field? (DQL63, DQL65)
    • How to display each DVIF in items as a table
      • case_FLST_HLSS : DQL10
      • case_FLST_HLSSS : DQL20
      • case_FLST_HLDSS : DQL30
      • case_FLST_HLDDD : DQL61, DQL63, DQL65

Q: How to design a note as a table in the database where each record consists of more than one field?

Answers

  • There are at least four methods to do that by using the file.lists data.
Code Name Data type Cases Headings(list items) Headings(task items) Remark
DQL10 file.lists case_FLST_HLSS milestones main tasks
DQL20 file.lists case_FLST_HLSSS some events some tasks
DQL30 file.lists case_FLST_HLDSS other events other tasks
DQL61 file.lists case_FLST_HLDDD what happened today what happened today
DQL63 file.lists case_FLST_HLDDD what happened today what happened today
DQL65 file.lists case_FLST_HLDDD what happened today what happened today

Q: How to gather list items or task items under the specific heading and display each DVIF in items as a table?

Answers: DQL10, DQL20, or DQL30

Q: How to gather root list items or root task items under the specific heading?

Answers: DQL61, DQL63, or DQL65

Q: How to distinguish list items from task items from the file.lists data?

Answers

  • How to distinguish list items from task items from the file.lists data?
    • a list item: !L.task
    • a task item: L.task
    • a root list item: !L.parent AND !L.task
    • a root task item: !L.parent AND 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 .

Exercises : DQL90

  • How to display list items or task items where the heading contains “what happened today” without the desired structure? (DQL90)
    • The DQL90 is copied from DQL07_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading in the following topic.
    • To gather list items or task items where the heading contains “what happened today”
    • To group by file.link and let G_file_link = rows.file.link;
    • To sort by G_file_link in descending order
    • To display the result as a table [without the desired structure]

Exercises : DVJS90


Test

Summary
  • dataview: v0.5.41

DQL10_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter: case_FLST_HLSS

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL10_flatten_fLists
_and_display_list_items
_and_task_items
_under_the_heading
_and_filter
file.lists yes 0.To require the note in the following form: case_FLST_HLSS
1.To flatten file.lists
2.To gather list items where the heading contains “milestones”
3.To gather task items where the heading contains “main tasks”
4.To filter by F_duration_days
5.To filter by L.tags and L.outlinks
6.To sort by file.link in ascending order
7.To display each DVIF in items as a table [without the desired structure]

Notes

require the note in the following form: case_FLST_HLSS

case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
FLST: Use file.lists
H: a header
L : an element of file.lists
S: field separators


  • filename : dic_20040301 contains the heading “milestones”
---
Date: 2004-03-01
---
#Project/P03

Areas:: #research


#### input
##### milestones
- 2004-03-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- 2004-03-02 add this feature_B #Test/d02 [[Note J]] 
- 2004-03-03 add this feature_C [[Note K]]
- 2004-03-04 add this feature_D #Test/d04
- 2004-03-05 add this feature_E  #Test/d05 [[Note K]] 
- 2004-03-06 add this feature_F  #Test/d06
- 2004-73-07 add this feature_G #Test/d07
- 2004-03-08 add this feature_H [[Note J]] , [[Note K]]
- 2004-03-09 add this feature_I 
- 2004-03-10 add this feature_J
- It is finished!



  • filename : dic_20040401 contains the heading “main tasks”
---
Date: 2004-04-01
---
#Project/P04

Areas:: #mocap


## input
### main tasks
- [ ] 2004-04-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-04-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 2004-04-03 add this feature_c  [[Note Q]]
- [ ] 2004-04-04 add this feature_d #Test/d04
- [x] 2004-04-05 add this feature_e  #Test/d05 [[Note Q]]
- [ ] 2004-04-06 add this feature_f  #Test/d06
- [ ] 2004-74-07 add this feature_g #Test/d07
- [ ] 2004-04-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 2004-04-09 add this feature_i 
- [ ] 2004-04-10 add this feature_j 
- [ ] It is finished!


Code DQL10_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter: case_FLST_HLSS

Summary_code
title: DQL10_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter =>0.To require the note in the following form: case_FLST_HLSS 
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "File",
      choice(L.task, "- [" + L.status + "] " + "",  "- " + "") AS "m_or_t",
      F_duration_days AS "dur_days",    
      F_text_without_outlinks AS "Event",
      F_sDate_of_L AS "L_sDate",
      F_fsDate_of_L AS "L_fsDate",
      L.tags AS "tags",
      L.outlinks AS "outlinks"

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE (contains(F_subpath, "milestones") AND F_type = "header")
      OR (contains(F_subpath, "main tasks") AND F_type = "header")
WHERE regexmatch("^\d{4}-\d{2}-\d{2}\s+", L.text)

FLATTEN split(L.text, " ")[0] AS F_sDate_of_L
FLATTEN regexreplace(L.text, "^\d{4}-\d{2}-\d{2} ", "") AS F_text_without_date
FLATTEN regexreplace(F_text_without_date, "\s+#.+$", "") AS F_text_without_tags
FLATTEN regexreplace(F_text_without_tags, "(\s+\[\[.+\]\].*$)", "") AS F_text_without_outlinks
WHERE F_sDate_of_L != null
WHERE date(F_sDate_of_L) != null

FLATTEN date(F_sDate_of_L) AS F_dtDate_of_L
FLATTEN dateformat(F_dtDate_of_L, "yyyy-MM-dd") AS F_fsDate_of_L
FLATTEN Date AS YAML_Date
FLATTEN dur(F_dtDate_of_L - YAML_Date).days AS F_duration_days
WHERE F_duration_days != 0
WHERE (contains(L.tags, "#Test/d05") AND contains(L.outlinks, [[Note K]]))
      OR (contains(L.tags, "#Test/d05") AND contains(L.outlinks, [[Note Q]]))
SORT file.link ASC

```

Screenshots(DQL10)


DQL20_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter: case_FLST_HLSSS

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL20_flatten_fLists
_and_display_list_items
_and_task_items
_under_the_heading
_and_filter
file.lists yes 0.To require the note in the following form: case_FLST_HLSSS
1.To flatten file.lists
2.To gather list items where the heading contains “some events”
3.To gather task items where the heading contains “some tasks”
4.To filter by L.tags
5.To sort by file.link in ascending order 6.To display each DVIF in items as a table [without the desired structure]

Notes

require the note in the following form: case_FLST_HLSSS

case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like “|”
FLST: Use file.lists
H: a header
L : an element of file.lists
S: field separators


  • filename : dic_20040301 contains the heading “some events”
---
Date: 2004-03-01
---
#Project/P03

Areas:: #research


#### input
##### some events
- 2004-03-01 | drinks | Black Coffee | 11 | #Test/d01 [[Note J]] , [[Note K]]
- 2004-03-02 | drinks | Black Coffee | 21 | #Test/d02  [[Note J]]
- 2004-03-03 | drinks | Black Coffee | 31 |  [[Note K]]
- 2004-03-04 | drinks | Black Coffee | 41 | #Test/d04
- 2004-03-05 | drinks | Black Coffee | 51 | #Test/d05 [[Note K]] 
- 2004-03-06 | drinks | Black Coffee | 61 | #Test/d06 
- 2004-73-07 | drinks | Black Coffee | 71 | #Test/d07
- 2004-03-08 | drinks | Black Coffee | 81 |  [[Note J]] , [[Note K]]
- 2004-03-09 | drinks | Black Coffee | 91
- 2004-03-10 | drinks | Black Coffee
- It is finished!


  • filename : dic_20040401 contains the heading “some tasks”
---
Date: 2004-04-01
---
#Project/P04

Areas:: #mocap


## input
### some tasks
- [ ] 2004-04-01 | drinks | Green Tea | 101 | #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-04-02 | drinks | Green Tea | 201 | #Test/d02  [[Note P]]
- [ ] 2004-04-03 | drinks | Green Tea | 301 |  [[Note Q]]
- [ ] 2004-04-04 | drinks | Green Tea | 401 | #Test/d04
- [x] 2004-04-05 | drinks | Green Tea | 501 | #Test/d05 [[Note Q]]
- [ ] 2004-04-06 | drinks | Green Tea | 601 | #Test/d06 
- [ ] 2004-74-07 | drinks | Green Tea | 701 | #Test/d07
- [ ] 2004-04-08 | drinks | Green Tea | 801 |  [[Note P]] , [[Note Q]]
- [ ] 2004-04-09 | drinks | Green Tea | 901
- [ ] 2004-04-10 | drinks | Green Tea
- [ ] It is finished!


Code DQL20_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter: case_FLST_HLSSS

Summary_code
title: DQL20_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter =>0.To require the note in the following form: case_FLST_HLSSS 1.To flatten file.lists 2.To gather list items where the heading contains "some events" 3.To gather task items where the heading contains "some tasks" 4.To filter by L.tags 5.To sort by file.link in ascending order 6.To display each DVIF in items as a table [without the desired structure]
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "File",
      choice(L.task, "- [" + L.status + "] " + "",  "- " + "") AS "m_or_t",
      F_sDate_of_L AS "L_sDate",
      F_fsDate_of_L AS "L_fsDate",
      F_type AS "type",
      F_desc AS "desc",
      F_cost AS "cost",
      L.tags AS "tags",
      L.outlinks AS "outlinks"   

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE contains(F_subpath, "some events") AND F_type = "header"
      OR (contains(F_subpath, "some tasks") AND F_type = "header")
WHERE regexmatch("^\d{4}-\d{2}-\d{2}\s+", L.text)

FLATTEN split(L.text, "\s+\|\s+")[0] AS F_sDate_of_L
FLATTEN split(L.text, "\s+\|\s+")[1] AS F_type
FLATTEN split(L.text, "\s+\|\s+")[2] AS F_desc
FLATTEN split(L.text, "\s+\|\s+")[3] AS F_cost
WHERE F_sDate_of_L != null
WHERE date(F_sDate_of_L) != null

FLATTEN date(F_sDate_of_L) AS F_dtDate_of_L
FLATTEN dateformat(F_dtDate_of_L, "yyyy-MM-dd") AS F_fsDate_of_L
WHERE contains(L.tags, "#Test/d02")
SORT file.link ASC

```

Screenshots(DQL20)


DQL30_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter: case_FLST_HLDSS

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL30_flatten_fLists
_and_display_list_items
_and_task_items
_under_the_heading
_and_filter
file.lists yes 0.To require the note in the following form: case_FLST_HLDSS
1.To flatten file.lists
2.To gather list items where the heading contains “other events”
3.To gather task items where the heading contains “other tasks”
4.To filter by L.tags
5.To sort by file.link in ascending order
6.To display each DVIF in items as a table [without the desired structure]

Notes

require the note in the following form: case_FLST_HLDSS

case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
FLST: Use file.lists
H: a header
L : an element of file.lists
D: DVIF
S: field separators


  • filename : dic_20040301 contains the heading “other events”
---
Date: 2004-03-01
---
#Project/P03

Areas:: #research


#### input
##### other events 
- info:: 2004-03-01 | drinks | Black Coffee | 12 | #Test/d01 [[Note J]] , [[Note K]]
- info:: 2004-03-02 | drinks | Black Coffee | 22 | #Test/d02  [[Note J]]
- info:: 2004-03-03 | drinks | Black Coffee | 32 |  [[Note K]]
- info:: 2004-03-04 | drinks | Black Coffee | 42 | #Test/d04
- info:: 2004-03-05 | drinks | Black Coffee | 52 | #Test/d05 [[Note K]] 
- info:: 2004-03-06 | drinks | Black Coffee | 62 | #Test/d06       
- info:: 2004-73-07 | drinks | Black Coffee | 72 | #Test/d07  
- info:: 2004-03-08 | drinks | Black Coffee | 82 | [[Note J]] , [[Note K]]  
- info:: 2004-03-09 | drinks | Black Coffee | 92  
- info:: 2004-03-10 | drinks | Black Coffee
- It is finished!


  • filename : dic_20040401 contains the heading “other tasks”
---
Date: 2004-04-01
---
#Project/P04

Areas:: #mocap


## input
### other tasks 
- [ ] (info:: 2004-04-01 | drinks | Green Tea | 102) #Test/d01 [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-04-02 | drinks | Green Tea | 202) #Test/d02  [[Note P]]
- [ ] (info:: 2004-04-03 | drinks | Green Tea | 302)  [[Note Q]]
- [ ] (info:: 2004-04-04 | drinks | Green Tea | 402) #Test/d04
- [x] (info:: 2004-04-05 | drinks | Green Tea | 502) #Test/d05 [[Note Q]]
- [ ] (info:: 2004-04-06 | drinks | Green Tea | 602) #Test/d06       
- [ ] (info:: 2004-74-07 | drinks | Green Tea | 702) #Test/d07  
- [ ] (info:: 2004-04-08 | drinks | Green Tea | 802)  [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-04-09 | drinks | Green Tea | 902) 
- [ ] (info:: 2004-04-10 | drinks | Green Tea) 
- [ ] It is finished!


Code DQL30_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter: case_FLST_HLDSS

Summary_code
title: DQL30_flatten_fLists_and_display_list_items_and_task_items_under_the_heading_and_filter =>0.To require the note in the following form: case_FLST_HLDSS 1.To flatten file.lists 2.To gather list items where the heading contains "other events" 3.To gather task items where the heading contains "other tasks" 4.To filter by L.tags 5.To sort by file.link in ascending order 6.To display each DVIF in items as a table [without the desired structure]
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "File",
      choice(L.task, "- [" + L.status + "] " + "",  "- " + "") AS "m_or_t",
      F_sDate_of_L AS "L_sDate",
      F_fsDate_of_L AS "L_fsDate",
      F_type AS "type",
      F_desc AS "desc",
      F_cost AS "cost",
      L.tags AS "tags",
      L.outlinks AS "outlinks"      

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type
WHERE contains(F_subpath, "other events") AND F_type = "header"
      OR (contains(F_subpath, "other tasks") AND F_type = "header")
WHERE L.info != null

FLATTEN split(L.info, "\s+\|\s+")[0] AS F_sDate_of_L
FLATTEN split(L.info, "\s+\|\s+")[1] AS F_type
FLATTEN split(L.info, "\s+\|\s+")[2] AS F_desc
FLATTEN split(L.info, "\s+\|\s+")[3] AS F_cost
WHERE F_sDate_of_L != null
WHERE date(F_sDate_of_L) != null

FLATTEN date(F_sDate_of_L) AS F_dtDate_of_L
FLATTEN dateformat(F_dtDate_of_L, "yyyy-MM-dd") AS F_fsDate_of_L
WHERE contains(L.tags, "#Test/d02")
SORT file.link ASC

```

Screenshots(DQL30)


DQL61_flatten_fLists_and_display_root_list_items_and_root_task_items_under_the_heading: case_FLST_HLDDD

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL61_flatten_fLists
_and_display
_root_list_items
_and_root_task_items
_under_the_heading
file.lists yes 0.To require the note in the following form: case_FLST_HLDDD
1.To flatten file.lists
2.To gather root list items or root task items where the heading contains “what happened today”
3.To sort by file.link in ascending order
4.To display each DVIF in root items as a table [without the desired structure]

Notes

require the note in the following form: case_FLST_HLDDD

case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
FLST: Use file.lists
H: a header
L : an element of file.lists
D: DVIF


  • filename : dic_20040301 contains the heading “what happened today”
---
Date: 2004-03-01
---
#Project/P03

Areas:: #research


#### input
##### what happened today?
- [type:: "food"] [desc:: "breakfast"] [cost:: 10] #Test/d01 [[Note J]] , [[Note K]]
- [type:: "food"] [desc:: "breakfast"] [cost:: 20] #Test/d02  [[Note J]]



  • filename : dic_20040401 contains the heading “what happened today”
---
Date: 2004-04-01
---
#Project/P04

Areas:: #mocap


## input
### what happened today?
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 100] #Test/d01 [[Note P]] , [[Note Q]]
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 200] #Test/d02  [[Note P]]



Code DQL61_flatten_fLists_and_display_root_list_items_and_root_task_items_under_the_heading: case_FLST_HLDDD

Summary_code
title: DQL61_flatten_fLists_and_display_root_list_items_and_root_task_items_under_the_heading =>0.To require the note in the following form: case_FLST_HLDDD 1.To flatten file.lists 2.To gather root list items or root task items where the heading contains "what happened today" 3.To sort by file.link in ascending order 4.To display each DVIF in root items as a table [without the desired structure]
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      file.link AS "File",
      choice(L.task, "- [" + L.status + "] " + "",  "- " + "") AS "m_or_t",
      L.type AS "type",
      L.desc AS "desc",
      L.cost AS "cost",
      L.tags AS "tags", 
      L.outlinks AS "outlinks",
      L.header AS "header"

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type

WHERE !L.parent
WHERE contains(F_subpath, "what happened today") AND F_type = "header"
SORT file.link ASC

```

Screenshots(DQL61)

Part 1/2

Part 2/2


DQL63_flatten_fLists_groupBy_fLink_and_display_root_list_items_under_the_heading_and_sum: case_FLST_HLDDD

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL63_flatten_fLists
_groupBy_fLink
_and_display
_root_list_items
_under_the_heading
_and_sum
file.lists yes 0.To require the note in the following form: case_FLST_HLDDD
1.To flatten file.lists
2.To gather root list items where the heading contains “what happened today”
3.To group by file.link and let G_file_link = rows.file.link;
4.To sort by G_file_link in descending order
5.To sum up rows.L.cost as “sum_r_cost”
6.To display each DVIF in root list items as a table [without the desired structure]

Code DQL63_flatten_fLists_groupBy_fLink_and_display_root_list_items_under_the_heading_and_sum: case_FLST_HLDDD

Summary_code
title: DQL63_flatten_fLists_groupBy_fLink_and_display_root_list_items_under_the_heading_and_sum =>0.To require the note in the following form: case_FLST_HLDDD 1.To flatten file.lists 2.To gather root list items where the heading contains "what happened today" 3.To group by file.link and `let G_file_link = rows.file.link;` 5.To sort by G_file_link in descending order 6.To sum up rows.L.cost as "sum_r_cost" 7.To display each DVIF in root list items as a table [without the desired structure]
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      G_file_link AS "File",
      rows.L.type AS "type",
      rows.L.desc AS "desc",
      rows.L.cost AS "cost",
      sum(map(rows.L.cost, (e) =>  sum(default(e, 0)))) AS "sum_r_cost",
      map(rows.L, (L) => choice(L.task, "- [" + L.status + "] ", "a list item")) AS "milestones_or_tasks"

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type

WHERE !L.parent AND !L.task
WHERE contains(F_subpath, "what happened today") AND F_type = "header"

GROUP BY file.link AS G_file_link
SORT G_file_link DESC

```

Screenshots(DQL63)


DQL65_flatten_fLists_groupBy_fLink_and_display_root_task_items_under_the_heading_and_sum: case_FLST_HLDDD

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL65_flatten_fLists
_groupBy_fLink
_and_display
_root_task_items
_under_the_heading
_and_sum
file.lists yes 0.To require the note in the following form: case_FLST_HLDDD
1.To flatten file.lists
2.To gather root task items where the heading contains “what happened today”
3.To group by file.link and let G_file_link = rows.file.link;
4.To sort by G_file_link in descending order
5.To sum up rows.L.cost as “sum_r_cost”
6.To display each DVIF in root task items as a table [without the desired structure]

Code DQL65_flatten_fLists_groupBy_fLink_and_display_root_task_items_under_the_heading_and_sum: case_FLST_HLDDD

Summary_code
title: DQL65_flatten_fLists_groupBy_fLink_and_display_root_task_items_under_the_heading_and_sum =>0.To require the note in the following form: case_FLST_HLDDD 1.To flatten file.lists 2.To gather root task items where the heading contains "what happened today" 3.To group by file.link and `let G_file_link = rows.file.link;` 4.To sort by G_file_link in descending order 5.To sum up rows.L.cost as "sum_r_cost" 6.To display each DVIF in root task items as a table [without the desired structure]
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      G_file_link AS "File",
      rows.L.type AS "type",
      rows.L.desc AS "desc",
      rows.L.cost AS "cost",
      sum(map(rows.L.cost, (e) =>  sum(default(e, 0)))) AS "sum_r_cost",
      map(rows.L, (L) => choice(L.task, "- [" + L.status + "] ", "a list item")) AS "milestones_or_tasks"

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type

WHERE !L.parent AND L.task
WHERE !rows.L.cost
WHERE contains(F_subpath, "what happened today") AND F_type = "header"

GROUP BY file.link AS G_file_link
SORT G_file_link DESC

```

Screenshots(DQL65)


Exercises : DQL90_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL90_flatten_fLists
_groupBy_fLink
_and_display_list_items
_and_task_items
_under_the_heading
file.lists yes 1.To flatten file.lists
2.To gather list items or task items where the heading contains “what happened today”
3.To group by file.link and let G_file_link = rows.file.link;
4.To sort by G_file_link in descending order
5.To display the result as a table [without the desired structure]
The DQL90 is copied from DQL07 in the following topic:
JonnyP: Grouping Tasks in Dataview by Content at 2022-08-23

Notes

dictionary files

  • filename : dic_20040301 contains the heading “what happened today”
---
Date: 2004-03-01
---
#Project/P03

Areas:: #research


#### input
##### what happened today?
- [type:: "food"] [desc:: "breakfast"] [cost:: 10] #Test/d01 [[Note J]] , [[Note K]]
- [type:: "food"] [desc:: "breakfast"] [cost:: 20] #Test/d02  [[Note J]]



  • filename : dic_20040401 contains the heading “what happened today”
---
Date: 2004-04-01
---
#Project/P04

Areas:: #mocap


## input
### what happened today?
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 100] #Test/d01 [[Note P]] , [[Note Q]]
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 200] #Test/d02  [[Note P]]



Code DQL90_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading

Summary_code
title: DQL90_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading =>1.To flatten file.lists 2.To gather list items or task items where the heading contains "what happened today" 3.To group by file.link and `let G_file_link = rows.file.link;` 4.To sort by G_file_link in descending order 5.To display the result as a table [without the desired structure]
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      G_file_link AS "File",
      map(rows.L, (L) => choice(L.task, "- [" + L.status + "] " + L.text,  L.text)) AS "milestones_or_tasks"

FROM "100_Project/02_dataview/Q92_FileLists/Q92_test_data" AND #Project

FLATTEN file.lists AS L
FLATTEN meta(L.header).subpath AS F_subpath
FLATTEN meta(L.header).type AS F_type

WHERE contains(F_subpath, "what happened today") AND F_type = "header"

GROUP BY file.link AS G_file_link
SORT G_file_link DESC

```

Screenshots(DQL90)

Part 1/3

Part 2/3

Part 3/3


Exercises : DVJS90_groupBy_fLink_flatten_fLists_and_taskList_under_the_heading

Summary

Main DVJS

Code Name Data type Group By Purposes Remark
DVJS90
_groupBy_fLink
_flatten_fLists
_and_taskList
_under_the_heading
file.lists yes
groupIn:no
1.To groupBy page.file.link as G1 (G1=group.rows)
2.To flatten page.file.lists
3.To gather a list item(or a task item) under the heading “what happened today”
4.To display the result by using the dv.taskList [with the desired structure]
The DVJS90 is copied from DVJS01 in the following topic:
johnnyvenom: The codeblock should display each project with the title as a header (H3) followed by the summary, and should group the projects by Area. at 2022-08-24

code DVJS90_groupBy_fLink_flatten_fLists_and_taskList_under_the_heading

Summary_code
title: DVJS90_groupBy_fLink_flatten_fLists_and_taskList_under_the_heading => 1.To groupBy page.file.link as G1 (G1=group.rows) 2.To flatten page.file.lists 3.To gather a list item(or a task item) under the heading "what happened today" 4.To display the result by using the dv.taskList [with the desired structure]
collapse: close
icon: 
color: 
```dataviewjs
// M11. define pages: gather all relevant pages
// #####################################################################
let pages = dv
    .pages('"100_Project/02_dataview/Q92_FileLists/Q92_test_data" and #Project')
    .where((page) => page.Areas);


// M21. define groups:
// To groupBy page.file.link AS G1 (G1=group.rows)
// #####################################################################
let groups = pages
    .groupBy((page) => page.file.link)
    .sort((group) => group.key, "desc");


// M31. output groups:
// #####################################################################
for (let group of groups) {

    // M31.FR13 define a_filtered_lists:
    // FLATTEN_CASE_10:To FLATTEN page.file.lists and gather them
    // WHERE_CASE_11  :To gather a list item(or a task item) 
    //                 under the heading "what happened today"
    // #####################################################################
    let a_filtered_lists = group.rows
        .flatMap((page) => page.file.lists)
        .where(
            (L) => dv.func.contains(L.header.subpath, "what happened today") && 
                   L.header.type === "header"
        );


    // M31.FR15 check a_filtered_lists.length :
    // #####################################################################
    if (a_filtered_lists.length === 0){
        continue;
    }
    
        
    // M31.FR21 output page.file.link :
    // #####################################################################
    dv.header(3, group.key);
    
    
    // M31.FR23 output a_filtered_lists.text: [with the desired structure]
    // #####################################################################
    dv.taskList(a_filtered_lists, false); 
}


```

Screenshots(DVJS90):

Part 1/2

Part 2/2


Wow, thanks a lot for that long post!!!

However, it’s kind of hard to understand your intention. Is this some kind of summary of good advises for working with dataview? Did you copy the parts out of some manual, if yes, which one?

Hi Alan,
I have two questions to these lines of code, you proposed to me:

  • If I understand that line correctly, dataviewjs is searching for all headers, which are identical with “## What happend today\?”, correct?
  • How did I have to modify that line, if I’d like to just search for headings, which contain “what happend”?
  • Yeah, I think, if my database continues to grow as fast as it did lately, dataviewjs-query could need a lot of time, so: how is it possible to filter that search?

Thanks in advance!
Silias

Topic: The file.lists by example (PART 2/2)


Input

Summary

dictionary files

  • Location: “100_Project/02_dataview/Q92_FileLists/Q92_test_data”

folder: 03_milestones

  • filename : dic_20040301
---
Date: 2004-03-01
---
#Project/P03

Areas:: #research


#### input
##### milestones
- 2004-03-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- 2004-03-02 add this feature_B #Test/d02 [[Note J]] 
- 2004-03-03 add this feature_C [[Note K]]
- 2004-03-04 add this feature_D #Test/d04
- 2004-03-05 add this feature_E  #Test/d05 [[Note K]] 
- 2004-03-06 add this feature_F  #Test/d06
- 2004-73-07 add this feature_G #Test/d07
- 2004-03-08 add this feature_H [[Note J]] , [[Note K]]
- 2004-03-09 add this feature_I 
- 2004-03-10 add this feature_J
- It is finished!

>case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


##### some events
- 2004-03-01 | drinks | Black Coffee | 11 | #Test/d01 [[Note J]] , [[Note K]]
- 2004-03-02 | drinks | Black Coffee | 21 | #Test/d02  [[Note J]]
- 2004-03-03 | drinks | Black Coffee | 31 |  [[Note K]]
- 2004-03-04 | drinks | Black Coffee | 41 | #Test/d04
- 2004-03-05 | drinks | Black Coffee | 51 | #Test/d05 [[Note K]] 
- 2004-03-06 | drinks | Black Coffee | 61 | #Test/d06 
- 2004-73-07 | drinks | Black Coffee | 71 | #Test/d07
- 2004-03-08 | drinks | Black Coffee | 81 |  [[Note J]] , [[Note K]]
- 2004-03-09 | drinks | Black Coffee | 91
- 2004-03-10 | drinks | Black Coffee
- It is finished!

>case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like "|"
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


##### other events 
- info:: 2004-03-01 | drinks | Black Coffee | 12 | #Test/d01 [[Note J]] , [[Note K]]
- info:: 2004-03-02 | drinks | Black Coffee | 22 | #Test/d02  [[Note J]]
- info:: 2004-03-03 | drinks | Black Coffee | 32 |  [[Note K]]
- info:: 2004-03-04 | drinks | Black Coffee | 42 | #Test/d04
- info:: 2004-03-05 | drinks | Black Coffee | 52 | #Test/d05 [[Note K]] 
- info:: 2004-03-06 | drinks | Black Coffee | 62 | #Test/d06       
- info:: 2004-73-07 | drinks | Black Coffee | 72 | #Test/d07  
- info:: 2004-03-08 | drinks | Black Coffee | 82 | [[Note J]] , [[Note K]]  
- info:: 2004-03-09 | drinks | Black Coffee | 92  
- info:: 2004-03-10 | drinks | Black Coffee
- It is finished!

>case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF
>S: field separators


##### what happened today?
- [type:: "food"] [desc:: "breakfast"] [cost:: 10] #Test/d01 [[Note J]] , [[Note K]]
- [type:: "food"] [desc:: "breakfast"] [cost:: 20] #Test/d02  [[Note J]]


>case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF



  • filename : dic_20040306
---
Date: 2004-03-06
---
#Project/P03

Areas:: #research


##### input
###### milestones
- 2004-03-01 add this feature_A #Test/d01 [[Note J]] , [[Note K]]
- 2004-03-02 add this feature_B #Test/d02 [[Note J]] 
- 2004-03-03 add this feature_C [[Note K]]
- 2004-03-04 add this feature_D #Test/d04
- 2004-03-05 add this feature_E  #Test/d05 [[Note K]] 
- 2004-03-06 add this feature_F  #Test/d06
- 2004-73-07 add this feature_G #Test/d07
- 2004-03-08 add this feature_H [[Note J]] , [[Note K]]
- 2004-03-09 add this feature_I 
- 2004-03-10 add this feature_J
- It is finished!

>case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


###### some events
- 2004-03-01 | drinks | Black Coffee | 16 | #Test/d01 [[Note J]] , [[Note K]]
- 2004-03-02 | drinks | Black Coffee | 26 | #Test/d02  [[Note J]]
- 2004-03-03 | drinks | Black Coffee | 36 |  [[Note K]]
- 2004-03-04 | drinks | Black Coffee | 46 | #Test/d04
- 2004-03-05 | drinks | Black Coffee | 56 | #Test/d05 [[Note K]] 
- 2004-03-06 | drinks | Black Coffee | 66 | #Test/d06 
- 2004-73-07 | drinks | Black Coffee | 76 | #Test/d07
- 2004-03-08 | drinks | Black Coffee | 86 |  [[Note J]] , [[Note K]]
- 2004-03-09 | drinks | Black Coffee | 96
- 2004-03-10 | drinks | Black Coffee
- It is finished!

>case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like "|"
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


###### other events 
- info:: 2004-03-01 | drinks | Black Coffee | 17 | #Test/d01 [[Note J]] , [[Note K]]
- info:: 2004-03-02 | drinks | Black Coffee | 27 | #Test/d02  [[Note J]]
- info:: 2004-03-03 | drinks | Black Coffee | 37 |  [[Note K]]
- info:: 2004-03-04 | drinks | Black Coffee | 47 | #Test/d04
- info:: 2004-03-05 | drinks | Black Coffee | 57 | #Test/d05 [[Note K]] 
- info:: 2004-03-06 | drinks | Black Coffee | 67 | #Test/d06       
- info:: 2004-73-07 | drinks | Black Coffee | 77 | #Test/d07  
- info:: 2004-03-08 | drinks | Black Coffee | 87 | [[Note J]] , [[Note K]]  
- info:: 2004-03-09 | drinks | Black Coffee | 97  
- info:: 2004-03-10 | drinks | Black Coffee
- It is finished!

>case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF
>S: field separators


###### what happened today?
- [type:: "food"] [desc:: "dinner"] [cost:: 36] #Test/d03
- (type:: "food") (desc:: "dinner") (cost:: 46) #Test/d04
- (type:: "food") %%(desc:: "dinner")%% %%(cost:: 56)%% #Test/d05
    - C1
        - C2
            - C3
                - C4
                    - C5
                        - C6


>case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF



folder: 04_tasks

  • filename : dic_20040401
---
Date: 2004-04-01
---
#Project/P04

Areas:: #mocap


## input
### main tasks
- [ ] 2004-04-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-04-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 2004-04-03 add this feature_c  [[Note Q]]
- [ ] 2004-04-04 add this feature_d #Test/d04
- [x] 2004-04-05 add this feature_e  #Test/d05 [[Note Q]]
- [ ] 2004-04-06 add this feature_f  #Test/d06
- [ ] 2004-74-07 add this feature_g #Test/d07
- [ ] 2004-04-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 2004-04-09 add this feature_i 
- [ ] 2004-04-10 add this feature_j 
- [ ] It is finished!


>case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


### some tasks
- [ ] 2004-04-01 | drinks | Green Tea | 101 | #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-04-02 | drinks | Green Tea | 201 | #Test/d02  [[Note P]]
- [ ] 2004-04-03 | drinks | Green Tea | 301 |  [[Note Q]]
- [ ] 2004-04-04 | drinks | Green Tea | 401 | #Test/d04
- [x] 2004-04-05 | drinks | Green Tea | 501 | #Test/d05 [[Note Q]]
- [ ] 2004-04-06 | drinks | Green Tea | 601 | #Test/d06 
- [ ] 2004-74-07 | drinks | Green Tea | 701 | #Test/d07
- [ ] 2004-04-08 | drinks | Green Tea | 801 |  [[Note P]] , [[Note Q]]
- [ ] 2004-04-09 | drinks | Green Tea | 901
- [ ] 2004-04-10 | drinks | Green Tea
- [ ] It is finished!


>case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like "|"
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


### other tasks 
- [ ] (info:: 2004-04-01 | drinks | Green Tea | 102) #Test/d01 [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-04-02 | drinks | Green Tea | 202) #Test/d02  [[Note P]]
- [ ] (info:: 2004-04-03 | drinks | Green Tea | 302)  [[Note Q]]
- [ ] (info:: 2004-04-04 | drinks | Green Tea | 402) #Test/d04
- [x] (info:: 2004-04-05 | drinks | Green Tea | 502) #Test/d05 [[Note Q]]
- [ ] (info:: 2004-04-06 | drinks | Green Tea | 602) #Test/d06       
- [ ] (info:: 2004-74-07 | drinks | Green Tea | 702) #Test/d07  
- [ ] (info:: 2004-04-08 | drinks | Green Tea | 802)  [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-04-09 | drinks | Green Tea | 902) 
- [ ] (info:: 2004-04-10 | drinks | Green Tea) 
- [ ] It is finished!


>case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF
>S: field separators


### what happened today?
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 100] #Test/d01 [[Note P]] , [[Note Q]]
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 200] #Test/d02  [[Note P]]


>case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF



  • filename : dic_20040406
---
Date: 2004-04-06
---
#Project/P04

Areas:: #mocap


### input
#### main tasks
- [ ] 2004-04-01 add this feature_a #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-04-02 add this feature_b #Test/d02  [[Note P]]
- [ ] 2004-04-03 add this feature_c  [[Note Q]]
- [ ] 2004-04-04 add this feature_d #Test/d04
- [x] 2004-04-05 add this feature_e  #Test/d05 [[Note Q]]
- [ ] 2004-04-06 add this feature_f  #Test/d06
- [ ] 2004-74-07 add this feature_g #Test/d07
- [ ] 2004-04-08 add this feature_h [[Note P]] , [[Note Q]]
- [ ] 2004-04-09 add this feature_i 
- [ ] 2004-04-10 add this feature_j 
- [ ] It is finished!


>case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


#### some tasks
- [ ] 2004-04-01 | drinks | Green Tea | 101 | #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-04-02 | drinks | Green Tea | 201 | #Test/d02  [[Note P]]
- [ ] 2004-04-03 | drinks | Green Tea | 301 |  [[Note Q]]
- [ ] 2004-04-04 | drinks | Green Tea | 401 | #Test/d04
- [x] 2004-04-05 | drinks | Green Tea | 501 | #Test/d05 [[Note Q]]
- [ ] 2004-04-06 | drinks | Green Tea | 601 | #Test/d06 
- [ ] 2004-74-07 | drinks | Green Tea | 701 | #Test/d07
- [ ] 2004-04-08 | drinks | Green Tea | 801 |  [[Note P]] , [[Note Q]]
- [ ] 2004-04-09 | drinks | Green Tea | 901
- [ ] 2004-04-10 | drinks | Green Tea
- [ ] It is finished!


>case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like "|"
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


#### other tasks 
- [ ] (info:: 2004-04-01 | drinks | Green Tea | 102) #Test/d01 [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-04-02 | drinks | Green Tea | 202) #Test/d02  [[Note P]]
- [ ] (info:: 2004-04-03 | drinks | Green Tea | 302)  [[Note Q]]
- [ ] (info:: 2004-04-04 | drinks | Green Tea | 402) #Test/d04
- [x] (info:: 2004-04-05 | drinks | Green Tea | 502) #Test/d05 [[Note Q]]
- [ ] (info:: 2004-04-06 | drinks | Green Tea | 602) #Test/d06       
- [ ] (info:: 2004-74-07 | drinks | Green Tea | 702) #Test/d07  
- [ ] (info:: 2004-04-08 | drinks | Green Tea | 802)  [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-04-09 | drinks | Green Tea | 902) 
- [ ] (info:: 2004-04-10 | drinks | Green Tea) 
- [ ] It is finished!


>case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF
>S: field separators


#### what happened today?
- [ ] [type:: "food"] [desc:: "dinner"] [cost:: 306] #Test/d03
- [x] (type:: "food") (desc:: "dinner") (cost:: 406) #Test/d04
- [ ] (type:: "food") %%(desc:: "dinner")%% %%(cost:: 506)%% #Test/d05
    - [ ] C1
        - [ ] C2
            - [ ] C3
                - [ ] C4
                    - [ ] C5
                        - [ ] C6


>case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF



folder: 05_empty

  • filename : dic_20040501
---
Date: 2004-05-01
---
#Project/P05

Areas:: #research


## input
### milestones
### some events
### other events 
### what happened today?



  • filename : dic_20040506
---
Date: 2004-05-06
---
#Project/P05

Areas:: #mocap


### input
#### main tasks
#### some tasks
#### other tasks
#### what happened today?



folder: 06_milestones_including_null

  • filename : dic_20040601
---
Date: 2004-06-01
---
#Project/P06

Areas:: #research


#### input
##### milestones
- 2004-06-01 add this feature_P #Test/d01 [[Note J]] , [[Note K]]
- 2004-06-02 add this feature_Q #Test/d02 [[Note J]] 
- 2004-06-03 add this feature_R [[Note K]]
- 2004-06-04 add this feature_S #Test/d04
- 2004-06-05 add this feature_T  #Test/d05 [[Note K]] 
- 2004-06-06 add this feature_U  #Test/d06
- 2004-76-07 add this feature_V #Test/d07
- 2004-06-08 add this feature_W [[Note J]] , [[Note K]]
- 2004-06-09 add this feature_X
- 2004-06-10 add this feature_Y
- It is finished!

>case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


##### some events
- 2004-06-01 | drinks | Hot Chocolate | 1001 | #Test/d01 [[Note J]] , [[Note K]]
- 2004-06-02 | drinks | Hot Chocolate | 2001 | #Test/d02  [[Note J]]
- 2004-06-03 | drinks | Hot Chocolate | 3001 |  [[Note K]]
- 2004-06-04 | drinks | Hot Chocolate | 4001 | #Test/d04
- 2004-06-05 | drinks | Hot Chocolate | 5001 | #Test/d05 [[Note K]] 
- 2004-06-06 | drinks | Hot Chocolate | 6001 | #Test/d06 
- 2004-76-07 | drinks | Hot Chocolate | 7001 | #Test/d07
- 2004-06-08 | drinks | Hot Chocolate | 8001 |  [[Note J]] , [[Note K]]
- 2004-06-09 | drinks | Hot Chocolate | 9001
- 2004-06-10 | drinks | Hot Chocolate
- It is finished!

>case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like "|"
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


##### other events
- info:: 2004-06-01 | drinks | Hot Chocolate | 1002 | #Test/d01 [[Note J]] , [[Note K]]
- info:: 2004-06-02 | drinks | Hot Chocolate | 2002 | #Test/d02  [[Note J]]
- info:: 2004-06-03 | drinks | Hot Chocolate | 3002 |  [[Note K]]
- info:: 2004-06-04 | drinks | Hot Chocolate | 4002 | #Test/d04
- info:: 2004-06-05 | drinks | Hot Chocolate | 5002 | #Test/d05 [[Note K]] 
- info:: 2004-06-06 | drinks | Hot Chocolate | 6002 | #Test/d06       
- info:: 2004-76-07 | drinks | Hot Chocolate | 7002 | #Test/d07  
- info:: 2004-06-08 | drinks | Hot Chocolate | 8002 | [[Note J]] , [[Note K]]  
- info:: 2004-06-09 | drinks | Hot Chocolate | 9002
- info:: 2004-06-10 | drinks | Hot Chocolate
- It is finished!

>case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF
>S: field separators


##### what happened today?
- [type:: "food"] [desc:: "breakfast"] [cost:: ] #Test/d01 [[Note K]]
- [type:: "food"] [desc:: "breakfast"] [cost:: 2000] #Test/d02  [[Note J]]

>case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF


folder: 07_tasks_including_null


  • filename : dic_20040701
---
Date: 2004-07-01
---
#Project/P07

Areas:: #mocap


## input
### main tasks
- [ ] 2004-07-01 add this feature_p #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-07-02 add this feature_q #Test/d02  [[Note P]]
- [ ] 2004-07-03 add this feature_r  [[Note Q]]
- [ ] 2004-07-04 add this feature_s #Test/d04
- [x] 2004-07-05 add this feature_t  #Test/d05 [[Note Q]]
- [ ] 2004-07-06 add this feature_u  #Test/d06
- [ ] 2004-77-07 add this feature_v #Test/d07
- [ ] 2004-07-08 add this feature_w [[Note P]] , [[Note Q]]
- [ ] 2004-07-09 add this feature_x 
- [ ] 2004-07-10 add this feature_y 
- [ ] It is finished!


>case_FLST_HLSS: use file.lists where L.text contains one field separator like " "
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


### some tasks
- [ ] 2004-07-01 | drinks | Iced Chocolate | 10001 | #Test/d01 [[Note P]] , [[Note Q]]
- [ ] 2004-07-02 | drinks | Iced Chocolate | 20001 | #Test/d02  [[Note P]]
- [ ] 2004-07-03 | drinks | Iced Chocolate | 30001 |  [[Note Q]]
- [ ] 2004-07-04 | drinks | Iced Chocolate | 40001 | #Test/d04
- [x] 2004-07-05 | drinks | Iced Chocolate | 50001 | #Test/d05 [[Note Q]]
- [ ] 2004-07-06 | drinks | Iced Chocolate | 60001 | #Test/d06 
- [ ] 2004-77-07 | drinks | Iced Chocolate | 70001 | #Test/d07
- [ ] 2004-07-08 | drinks | Iced Chocolate | 80001 |  [[Note P]] , [[Note Q]]
- [ ] 2004-07-09 | drinks | Iced Chocolate | 90001
- [ ] 2004-07-10 | drinks | Iced Chocolate
- [ ] It is finished!


>case_FLST_HLSSS: use file.lists where L.text contains at least one field separator like "|"
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>S: field separators


### other tasks
- [ ] (info:: 2004-07-01 | drinks | Iced Chocolate | 10002) #Test/d01 [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-07-02 | drinks | Iced Chocolate | 20002) #Test/d02  [[Note P]]
- [ ] (info:: 2004-07-03 | drinks | Iced Chocolate | 30002)  [[Note Q]]
- [ ] (info:: 2004-07-04 | drinks | Iced Chocolate | 40002) #Test/d04
- [x] (info:: 2004-07-05 | drinks | Iced Chocolate | 50002) #Test/d05 [[Note Q]]
- [ ] (info:: 2004-07-06 | drinks | Iced Chocolate | 60002) #Test/d06       
- [ ] (info:: 2004-77-07 | drinks | Iced Chocolate | 70002) #Test/d07  
- [ ] (info:: 2004-07-08 | drinks | Iced Chocolate | 80002)  [[Note P]] , [[Note Q]]
- [ ] (info:: 2004-07-09 | drinks | Iced Chocolate | 90002) 
- [ ] (info:: 2004-07-10 | drinks | Iced Chocolate) 
- [ ] It is finished!


>case_FLST_HLDSS: use file.lists where L.text consists of one DVIF and field separators
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF
>S: field separators


### what happened today?
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: ] #Test/d01 [[Note Q]]
- [ ] [type:: "food"] [desc:: "breakfast"] [cost:: 20000] #Test/d02  [[Note P]]


>case_FLST_HLDDD: use file.lists where L.text consists of more than one DVIF
>FLST: Use file.lists
>H: a header
>L : an element of file.lists
>D: DVIF




Related resources

Summary

Oh, anytime!

You could use DQL90 or DVJS90 to display the content under the heading :“what happened today”.

Summary

DQL90

  • The DQL90 is copied from DQL07_flatten_fLists_groupBy_fLink_and_display_list_items_and_task_items_under_the_heading in the following topic.
    • The file.lists by example - Chapter 1: using DQL to gather list items or task items under the specific heading
    • Links: Solutions=>JonnyP: Grouping Tasks in Dataview by Content at 2022-08-23
    • You could read the following questions under the heading “Topic : file.lists by example”
      • Q: How to use FROM source for best performance when using DQL?
      • Q: What does the following DQL statement mean?
      • Q: How to use F_subpath to filter by the specific heading when using DQL?

DVJS90


You should ignore the other DQLs at present.


Q: How did I have to modify that line, if I’d like to just search for headings, which contain “what happend”?

Summary

for DQL90

the original example

WHERE contains(F_subpath, "what happened today") AND F_type = "header"

the new example

WHERE contains(F_subpath, "what happend") AND F_type = "header"

for DVJS90

the original example

    // M31.FR13 define a_filtered_lists:
    // FLATTEN page.file.lists and gather them: 
    // get items under the heading "Summary"
    // #####################################################################
    let a_filtered_lists = group.rows
        .flatMap((page) => page.file.lists)
        .where(
            (L) => dv.func.contains(L.header.subpath, "what happened today") && 
                   L.header.type === "header"
        );

the new example

    // M31.FR13 define a_filtered_lists:
    // FLATTEN page.file.lists and gather them: 
    // get items under the heading "Summary"
    // #####################################################################
    let a_filtered_lists = group.rows
        .flatMap((page) => page.file.lists)
        .where(
            (L) => dv.func.contains(L.header.subpath, "what happened") && 
                   L.header.type === "header"
        );

That gets a little tricksy, but not hard to do.

The search is using what’s called a “regular expression”, or “regex”:

To find any headers that contain the text “what happened”, change the variable like so:

const header = '#+ [^\n]*?what happened'

This is looking for:

  • #+ match any line that starts with any number of hash symbols followed by a space, i.e. any header level
  • [^\n]*? match any character that is NOT a new line character
  • what happened match your exact text

Just check the Dataview docs, or any of the many threads on this forum talking about how to use Dataview:

https://blacksmithgu.github.io/obsidian-dataview/data-queries/

Here’s how you find only pages with a daily tag:

const pages = dv.pages('#daily')

Hi Alan,

thanks again for your tipps.
Unfortunately, they aren’t working yet.

This is my actual code (which I have from you), which searches all of my files and works pretty good, but needs some time, to load (the ``` at the beginning and the end of the code are not shown):

dataviewjs
const header = '## What happend today\\?'

// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages().sort(x => x.file.name, 'desc')

// This regex will return text from the Summary header, until it reaches
// the next header, a horizontal line, or the end of the file
const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')

for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    const summary = contents.match(regex)
    if (summary && summary[1].trim()) {
        // Output the header and summary
        dv.header(2, file.basename)
        dv.paragraph(summary[1].trim())
    }
}

And here’s my code, with your first tipp included:

dataviewjs
const header = '#+ [^\n]*?what happened'

// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages().sort(x => x.file.name, 'desc')

// This regex will return text from the Summary header, until it reaches
// the next header, a horizontal line, or the end of the file
const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')

for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    const summary = contents.match(regex)
    if (summary && summary[1].trim()) {
        // Output the header and summary
        dv.header(2, file.basename)
        dv.paragraph(summary[1].trim())
    }
}

Result:
Unfortunately, it doesnt show anything…

And here’s my code, with your second tipp included:

dataviewjs
const header = '## What happend today\\?'

// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages('#daily').sort(x => x.file.name, 'desc')

// This regex will return text from the Summary header, until it reaches
// the next header, a horizontal line, or the end of the file
const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')

for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    const summary = contents.match(regex)
    if (summary && summary[1].trim()) {
        // Output the header and summary
        dv.header(2, file.basename)
        dv.paragraph(summary[1].trim())
    }
}

Same here, no result…

I assume, I inserted your additions at the wrong place, or did something else wrong?

Thanks in advance!
kind regards,
Silias

Here’s a 100% working demo vault.

It looks for all notes with the #daily tag, and which have a heading that contains the words “what happened”.

Go to the Dataview code note.

https://drive.google.com/file/d/1Fdt8_sRAPFrvYJuYwqmouGZMRPN8WTa_/view?usp=sharing

1 Like

Hi Alan,

wow, thanks!!! Your Demo vault works perfectly!

Now a few last question to your demo vault:
In your demo vault, the headers in all files with the hashtag #daily, are searched for the string “what happend”.

=> Questions:
How should I modify that search, if

  • I want a OR-query, e.g. if I want to get results from all files, that are taged with #daily OR #diary
  • I don’t want to filter by the tag #daily, but by foldername or if I just want to search the actual note (this.file)?
  • I realised, that the query just finds the first header with the string “what happend” in one file. How should I modify the code, if I want to get all headers in one file, that contain the string “what happend”? (Yeah, I know, that question doesn’t fit anymore to the usecase of a daily-note-summary, because I only have one header with the string “what happend” in each daily note - but imagine the usecase of a project-protocoll, with headers for each conversation: then I’d like to query that protocol for all conversations for example with “frank”)

Thanks :slight_smile:

As in my previous message, I recommend that you have a look at a beginners Javascript course. There’s an amazing German instructor who I love, and this is where I learned Javascript:

https://www.udemy.com/course/javascript-the-complete-guide-2020-beginner-advanced/

It’s very easy, and it will open up a world of possibilities for you in Obsidian and so many other applications. The course should be around $10. If not, wait until Udemy has a discount (every other day basically).

1 Like

Thanks for the code. I’ve got a Regex problem. As far as I understand Regex doesn’t recognize Turkish characters. Such as “şüğçöıİÜĞÇÖŞ”. I’ve got these characters in my heading. How can I get regex to find them?
I’ve found jquery - Javascript: RegExp Turkish Character Issue - Stack Overflow this. But didn’t understand how to solve it.

The problem in the linked post is that word boundaries (\b) don’t work with Turkish characters. That probably isn’t your issue, though.

Make sure you’ve rewritten this line to match the correct pages (e.g. using the right tag):

const pages = dv.pages('#daily').sort((x) => x.file.name, 'desc');

If that doesn’t fix anything, comment with your note’s markdown and your dataviewjs code. We can double-check your work with you.

I’ve changed it to #günlük. If I use a header that doesn’t contain Turkish characters there is no problem. But when I use Turkish chars it fails.

Below is my code and error I’ve got.
After seeing the post, I noticed Allah'a “a” was highlighted. So I changed the header to const header = '## Şükürler olsun ki: ' now it works. Maybe the problem was '.

Thanks for your interest. :slight_smile:

```dataviewjs
const header = '## Allah'a şükürler olsun ki:'

// You can update this to filter as you like - filtering for just your daily notes would be good
const pages = dv.pages('#günlük').sort(x => x.file.name, 'desc')

// This regex will return text from the Summary header, until it reaches
// the next header, a horizontal line, or the end of the file
const regex = new RegExp(`\n${header}\r?\n(.*?)(\n#+ |\n---|$)`, 's')

for (const page of pages) {
    const file = app.vault.getAbstractFileByPath(page.file.path)
    // Read the file contents
    const contents = await app.vault.read(file)
    // Extract the summary via regex
    const summary = contents.match(regex)
    if (summary) {
        // Output the header and summary
        dv.header(2, file.basename)
        dv.paragraph(summary[1].trim())
    }
}


Evaluation Error: SyntaxError: Unexpected identifier
at DataviewInlineApi.eval (plugin:dataview:19669:21)
at evalInContext (plugin:dataview:19670:7)
at asyncEvalInContext (plugin:dataview:19677:16)
at DataviewJSRenderer.render (plugin:dataview:19701:19)
at DataviewJSRenderer.onload (plugin:dataview:19285:14)
at DataviewJSRenderer.e.load (app://obsidian.md/app.js:1:730611)
at t.e.addChild (app://obsidian.md/app.js:1:731035)
at t.addChild (app://obsidian.md/app.js:1:1646061)
at Object.addChild (app://obsidian.md/app.js:1:1645086)
at DataviewApi.executeJs (plugin:dataview:20210:19)
at DataviewPlugin.dataviewjs (plugin:dataview:20708:18)
at eval (plugin:dataview:20632:105)
at t.render (app://obsidian.md/app.js:1:1644987)
at enter (app://obsidian.md/app.js:1:1655590)
at e.iterate (app://obsidian.md/app.js:1:293053)
at ei.iterate (app://obsidian.md/app.js:1:1541428)
at e.update [as updateF] (app://obsidian.md/app.js:1:1652588)
at Object.update (app://obsidian.md/app.js:1:347440)
at e. (app://obsidian.md/app.js:1:358213)
at Pr (app://obsidian.md/app.js:1:351383)
at new e (app://obsidian.md/app.js:1:357239)
at e.applyTransaction (app://obsidian.md/app.js:1:358155)
at e.get (app://obsidian.md/app.js:1:353387)
at e.update (app://obsidian.md/app.js:1:495674)
at e._dispatch (app://obsidian.md/app.js:1:493593)
at e.dispatch (app://obsidian.md/app.js:1:495249)
at app://obsidian.md/app.js:1:1656774
at r (plugin:obsidian-kindle-plugin:333:35922)

Yes, the ' was causing your problem. You should be able to fix the issue without changing your header, then. Use double-quotes instead of single-quotes in the code, like so:

const header = "## Allah'a şükürler olsun ki:"

Cheers.

1 Like

I’m trying to get this working with my daily notes. I have my daily notes tagged #daily and I’m trying to compile the section 3 Sentences or more on the day to another note.

This is what the code I have in there looks like:

I get the error message below, any tips?

Evaluation Error: SyntaxError: Unexpected end of input
at DataviewInlineApi.eval (plugin:dataview:19669:21)
at evalInContext (plugin:dataview:19670:7)
at asyncEvalInContext (plugin:dataview:19677:16)
at DataviewJSRenderer.render (plugin:dataview:19701:19)
at DataviewJSRenderer.onload (plugin:dataview:19285:14)
at DataviewJSRenderer.e.load (app://obsidian.md/app.js:1:730611)
at t.e.addChild (app://obsidian.md/app.js:1:731035)
at t.eval (plugin:obsidian-query-control:6:6224)
at t.n [as addChild] (plugin:obsidian-query-control:6:1118)
at t.addChild (app://obsidian.md/app.js:1:1646061)