Grouping tasks by day of the week in defined order (instead of alphabetical)

What I’m trying to do

To display tasks that happen during the current week grouped by the day of the week in proper order (as opposed to alphabetical).

The following groups by day of the week in the order Monday, Friday, Thursday, Tuesday, Saturday, Sunday, Wednesday:

tasks
filter by function 'TODO'.includes(task.status.type)
happens this week
GROUP by function task.happens.format("dddd")

Things I have tried

Based on the example here I came up with the following unsuccessful solution:

tasks
filter by function 'TODO'.includes(task.status.type)
happens this week
group by choice(task.happens.format("dddd") = "Monday", 1, task.happens.format("dddd") = "Tuesday", 2, task.happens.format("dddd") = "Wednesday", 3, task.happens.format("dddd") = "Thursday", 4, task.happens.format("dddd") = "Friday", 5, task.happens.format("dddd") = "Saturday", 6, task.happens.format("dddd") = "Sunday", 7)

Can you also please show your input? Some examples of the format of the tasks you are querying.

@rigmarole the tasks include any traditionally formatted task items and I use of the obsidian-tasks plugin. Each task is followed by any combination of dates, at least one of which qualifies as “happens” (the earliest of start date, scheduled date, and due date).

- [ ] task A  ⏳ 2024-10-25 
- [-] task B ⏬  ⏳ 2024-10-25 ❌ 2024-10-22
- [x] task C 🛫 2024-10-22 ✅ 2024-10-21

Thanks, that should help someone help you. I can’t quite figure out how to format the FLATTEN and GROUP and SORT.

But there are some additional examples in the tasks documentation: Grouping - Tasks User Guide - Obsidian Publish

You can’t mix syntax from tasks and dataview and expect it to work. It seems like you’ve the first part with syntax from the tasks plugin (and your code block also indicates this), and then you try to use group by and flatten as if it was an dataview query. (And your example is from the Dataview documentation)

You need to decide which plugin to use for this query, and read the corresponding documentation.

1 Like

ah yeah, good point, I took for granted the linked page had valid syntax for tasks. Edited my post to remove the tests I was trying.

Thanks @holroy – I didn’t realize I had conflated the two. Thanks for pointing that out!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.