DataviewJS Example: Grouping Journal/Daily Note by Date (Month), Filtering by List w/ Tag, and Outputting a Markdown List w/ Children

function listChildren(children, offset = "   ") {
	let result = "\n"
	for (const child of children) {
		result += offset + "- " +
			(child.task ? `[${ child.status ?? " "}] ` : "" ) +
			child.text + "\n"
		if (child.children.length) {
			result += listChildren(child.children, offset + "  ") 
		}
	}
	return result
}

let pages = dv.pages('"Journal"').filter(p => p.date)
let months = pages.groupBy(p => DateTime.fromISO(p.date).toFormat("%%yyyy-MM%%MMMM yyyy"))

for (let month of months) {
    let lists = pages.where(p => p.date && DateTime.fromISO(p.date).toFormat("%%yyyy-MM%%MMMM yyyy") == month.key).file.lists;
    let keyIdeas = lists.filter(l => l.tags && dv.func.contains(l.tags, "#pin"))
	
	if(keyIdeas.length > 0) { dv.header(4, `${ month.key }`); }
	dv.paragraph(dv.markdownList(
		keyIdeas.map(l => l.text + listChildren(l.children))
	))
}

For in case anyone has a weirdly-specific DataviewJS query and needs an example.

Related Forum Posts:

  1. How do you group by twice in either dataview or dataviewjs?
  2. https://www.reddit.com/r/ObsidianMD/comments/10pat4x/dataviewjs_grouping_by_month_and_year_with_more/
  3. [DataviewJS] Filtering query using dates
  4. Filtering a list in DataviewJS - #2 by AlanG