Skip to content

How to group tasks by File and then by Section? #720

Answered by ces3001
claremacrae asked this question in Q&A
Discussion options

You must be logged in to vote

This should work to group and sort the tasks by order of appearance of the sections and not alphabetically.
taskList can contain tasks from multiple files as well, just change the first taskList = line to get the tasks you want.

	```dataviewjs
	const summary = true
	const includeSection = true
	let taskList = dv.current().file.tasks
				 .where(t => !t.completed && dv.date(t.start) <= dv.date('today'))
	taskList = taskList
		.sort(t => t.line)
		.sort(t => t.path)
	if (summary) { dv.span("*" + taskList.length + " tasks*\n") }
	if (includeSection) {
		const regex = /> ([^\]]+)/;
		let section = null
		let page = null
		let sectionTaskList = []
		for (let t of taskList) {
			if ((sectionTas…

Replies: 7 comments 12 replies

Comment options

You must be logged in to vote
1 reply
@jesvtb
Comment options

Comment options

You must be logged in to vote
4 replies
@MugenLee
Comment options

@senged
Comment options

@AB1908
Comment options

@claremacrae
Comment options

Comment options

You must be logged in to vote
2 replies
@AB1908
Comment options

@claremacrae
Comment options

Comment options

You must be logged in to vote
1 reply
@claremacrae
Comment options

Comment options

You must be logged in to vote
2 replies
@acdesigns
Comment options

@claremacrae
Comment options

Comment options

You must be logged in to vote
2 replies
@claremacrae
Comment options

@timespaced
Comment options

Answer selected by claremacrae
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants