Sort Ascending null dates with DataviewJS

What I’m trying to do

I have a collection of files with a property ‘DueDate’. I am trying to create a table which lists these in ascending order, but with the null values at the bottom of the list.

In DQL I used

SORT choice(!DueDate, date(2100-01-01), due-date) ASC

My current dataviewjs code is:

const {fieldModifier: f} =["metadata-menu"].api;
const aliases = dv.current().file.aliases
dv.table(["Status","Task","Due Date"],
await Promise.all(dv.pages('"Task Management System/Tasks"')
.where(p => p.Status !="Completed")
.sort(p => p.DueDate, 'asc')
.map(async p => [
	await f(dv, p, "Status"),
	"[[" + + "|" + (p.file.aliases[1] || p.file.aliases[0]) + "]]",

So I am looking for a way to recreate the choice function in dataviewjs (although I suspect it’s not that simple).

Things I have tried

I have not been able to find much help through use of Google etc - I suspect this is because I am on the wrong path with what I am even looking for here. I suspect I want to substitute a date far in the future for the Null values, like the choice command in DQL, but am not clear how to do this.

Thanks in advance

1 Like

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