Sorting by date

I have some notes, some with deadline, some without. I want to use dataview to sort them by deadline such that the closest deadline is at the top, and the ones without deadline are at the bottom, below the one with the deadline farthest into the future.

What I’m trying to do

dataview
Table
deadline as "Deadline"
FROM #tag
WHERE status="active"
SORT deadline

Is what I’m currently doing, but the default sorting puts the notes without deadline at the top.
How would I do that?

There is a function, default(), which takes two parameters. It’ll return the first parameter, if it’s defined, and if it’s not defined it’ll default to the second parameter.

In your case you could use this on the deadline field, so that it is used if defined, but if it’s not defined you can set which date to use to make it sort correctly.

You state you want those without a deadline on the bottom, so use a date somewhere in the future, like:

SORT default(deadline, date("2200-12-31"))

Code untested, but it should work.

Works like a charm. Thank you

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