Comments (12)
You can put them in fenced code blocks, for readability.
Transparency note: I have put the samples provided in to fenced code blocks, so they are easier to see.
from obsidian-tasks.
... and easy to copy ...
from obsidian-tasks.
Hi, thanks for the suggestion.
Please could we have an explanation that does not require understanding SQL?
The best way to explain it would be to:
- provide a few carefully selected markdown task lines
- show what the desired
sort orderdisplay of those tasks would be, if this facility were provided.
The above should all be in text, so that they can be copied in to Obsidian. You can put them in fenced code blocks, for readability.
Many thanks.
from obsidian-tasks.
I've edited the wording above slightly, to make it more general than just sort order.
from obsidian-tasks.
Thanks for the quick reply, Clare. Thought my verbal explanation would suffice, but I'll attempt an example.
Here's four tasks:
- [ ] Write up minutes from board meeting 🛫 2024-04-07 📅 2024-04-10
- [ ] Review my Reading folder on Gmail 🔁 every week when done 🛫 2024-04-09 ⏳ 2024-04-11
- [ ] Process snail mail 🔼 🔁 every week when done 🛫 2024-04-09 🛫 2024-04-09
- [ ] Wipe down kitchen cupboards 🔽 🔁 every 3 months when done 🛫 2024-04-07 ⏳ 2024-04-09
If I write:
> group by scheduled
> group by due
> group by start
The output looks like this:
2025-04-09 Wednesday
No due date
2025-04-07 Monday
- [ ] Wipe down kitchen cupboards 🔽 🔁 every 3 months when done 🛫 2025-04-07 ⏳ 2025-04-09
2025-04-11 Friday
No due date
2025-04-09 Wednesday
- [ ] Review my Reading folder on Gmail 🔁 every week when done 🛫 2025-04-09 ⏳ 2025-04-11
No scheduled date
2025-04-10 Thursday
2025-04-07 Monday
- [ ] Write up minutes from board meeting 🛫 2025-04-07 📅 2025-04-10
No due date
2025-04-09 Wednesday
- [ ] Process snail mail 🔼 🔁 every week when done 🛫 2025-04-09
What I'd like to be able to do is write:
> group by scheduled, due, start
And have the output look like this:
2025-04-09 Wednesday
- [ ] Wipe down kitchen cupboards 🔽 🔁 every 3 months when done 🛫 2025-04-07 ⏳ 2025-04-09
- [ ] Process snail mail 🔼 🔁 every week when done 🛫 2025-04-09
2025-04-10 Thursday
- [ ] Write up minutes from board meeting 🛫 2025-04-07 📅 2025-04-10
2025-04-11 Friday
- [ ] Review my Reading folder on Gmail 🔁 every week when done 🛫 2025-04-09 ⏳ 2025-04-11
2025-04-07 Monday
As you can see above, the output is the same as a single group by statement. However, if there's no SCHEDULED DATE (the primary grouping field), the secondary grouping field (i.e., DUE DATE) is used if it exists (e.g., Thursday above). And if neither of those fields has a value, the tertiary grouping field (i.e., START DATE) is used (second task in Wednesday above).
Would love to see this implemented for sorts as well!
from obsidian-tasks.
Thank you.
Please also show the output for how you envisage this for sorting?
from obsidian-tasks.
Also, please could you try these two commands out (separately) and see if they are close enough for you?
group by happens
sort by happens
from obsidian-tasks.
The problem with HAPPENS in this context and others is that it always uses the earliest of the three dates. If there were a way to make it ignore the start date (which is almost always the earliest date), HAPPENS would be much more useful (to me at least).
As for a sort example, I'd like to be able to enter:
> SORT BY SCHEDULED, DUE, START
And get output that looks like this:
- [ ] Wipe down kitchen cupboards 🔽 🔁 every 3 months when done 🛫 2025-04-07 ⏳ 2025-04-09
- [ ] Process snail mail 🔼 🔁 every week when done 🛫 2025-04-09
- [ ] Write up minutes from board meeting 🛫 2025-04-07 📅 2025-04-10
- [ ] Review my Reading folder on Gmail 🔁 every week when done 🛫 2025-04-09 ⏳ 2025-04-11
As you can see above, the first task has a SCHEDULED DATE so that's what's used for the sort. Because the second task has no SCHEDULED or DUE DATE, its START DATE is used for sorting. Since the third task has a DUE DATE, that's what is used for sorting.
from obsidian-tasks.
Thanks again for the suggestion.
Thanks to your supplying text examples, I have been able to experiment and find that this is already possible in Tasks.
```tasks
group by function \
{{! Get the dates, in order of priority: }} \
const dates = [task.scheduled, task.due, task.start]; \
{{! Find the first non-null date. Returns undefined if no date set: }} \
const first = dates.find((date) => date.moment != null); \
if (first) return first.formatAsDate(); \
return '';
```
Make sure you Shift-paste this in to Obsidian, to avoid stray spaces being added at the end of each line, which will break the \
facility.
This gives me:
from obsidian-tasks.
Thanks for this, Clare. Aside from the dropping of the day's name, this appears to be the precise output I'm seeking. That said, Tasks has served me well to this point without me having to construct anything near as elaborate as this and I suspect many user of the Plugin wouldn't know where to start in trying to write this piece of code. So in an effort to make this functionality available to more people, I hope you'll at least consider implementing something similar to what I've suggested.
from obsidian-tasks.
And here is how you could do it for sorting:
```tasks
sort by function \
{{! Get the dates, in order of priority: }} \
const dates = [task.scheduled, task.due, task.start]; \
{{! Find the first non-null date. Returns undefined if no date set: }} \
const first = dates.find((date) => date.moment != null); \
if (first) return first; \
{{! None of the dates has a value, so just return the first one, to ensure correct sorting }} \
return dates[0];
```
I added a task with date, to confirm the behaviour for that scenario:
from obsidian-tasks.
Thanks for this, Clare. Aside from the dropping of the day's name, this appears to be the precise output I'm seeking.
Sure. The formatting is because I used first.formatAsDate()
.
The docs show how you can control the formatting of dates.
That said, Tasks has served me well to this point without me having to construct anything near as elaborate as this and I suspect many user of the Plugin wouldn't know where to start in trying to write this piece of code. So in an effort to make this functionality available to more people, I hope you'll at least consider implementing something similar to what I've suggested.
I understand what you are saying, and I sympathise.
And in fact, since releasing the custom grouping, filtering and sorting facilities, I have wanted to make some of their capabilities available without the need for scripting.
But that has got nowhere near the top of the priority list, given the huge number of requests in Issues and Discussions.
In the meantime, a handful of times a month I receive rather specific requests from users, such as this one, for which there would just never be enough time for me to make them all available. And it's often not completely obvious that large enough numbers of users would to use them, to make it worth the required effort to develop, test, document and maintain each new feature.
So the current compromise is to spend a few minutes experimenting with text supplied by users to show them how to use the powerful scripting capabilities.
I will add these examples to the documentation.
from obsidian-tasks.
Related Issues (20)
- My Task Dependencies are working inverse from the documentation (error in documentation) HOT 4
- Option to disable assignment of scheduled date for recurring tasks HOT 10
- "cancelled on" filter does not work on 6.2.0 for android HOT 5
- Tasks with pictures cannot be displayed correctly HOT 4
- Tasks become doubled in reading mode HOT 4
- Inherit task type [when pressing return in the editor] HOT 2
- Tasks 7.0.0 freezes with Iconize 2.11.11 HOT 5
- Leverage task dependency implementation to add subtasks HOT 13
- Auto suggest prevents other plugin's EditorSuggests from opening on task lines HOT 5
- Option to make recurring tasks inherit ID and dependency HOT 10
- Make separator between dataview components configurable HOT 2
- Today and future data-task-due are messy [date-based CSS errors for non-UTC timezones] HOT 26
- Automatic creation date HOT 29
- Inconsistent sort order of groups by date categories (sometimes)
- Use filename as Scheduled date for undated tasks. HOT 4
- Task completion sound HOT 1
- some text breaks due date query HOT 2
- Subtasks flag/mark to see that task in overview has a sub-items HOT 2
- use filename for undated tasks HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from obsidian-tasks.