Formulas for bases sort/grouping order

Use case or problem

I’m using a bases view to manage tasks. I’m using a formula to group tasks into due date ranges. Examples include “in progress”, “today”, “Friday”, “next week”. I’d like to sort them in chronological order, not alphabetically.

Proposed solution

In the “group by” and “sort by” fields in a Base, the options are A>Z and Z<A, the proposal is to add the ability to enter a formula, or a comparison function, similar to JS array.sort().

Current workaround (optional)

Currently I prefix my groups with a number, so “00 Today”, “10 Next week”, etc. This works ok.

Sharing my formula here.

if(formula.Contexts.isEmpty(),
"00 Inbox",

if(due < today(),
"01 Overdue",

if(formula.Scheduled < today(),
"02 In Progress",

if(formula.Scheduled == today(),
"03 Today",

if(formula.Scheduled.format("W") == today().format("W") && formula.Scheduled == today() + "1d",
"04 Tomorrow",

if(formula.Scheduled.format("W") == today().format("W") && formula.Scheduled == today() + "2d",
"05 " + formula.Scheduled.format("dddd"),

if(formula.Scheduled.format("W") == today().format("W") && formula.Scheduled == today() + "3d",
"06 " + formula.Scheduled.format("dddd"),

if(formula.Scheduled.format("W") == today().format("W") && formula.Scheduled == today() + "4d",
"07 " + formula.Scheduled.format("dddd"),

if(formula.Scheduled.format("W") == today().format("W") && formula.Scheduled == today() + "5d",
"08 " + formula.Scheduled.format("dddd"),

if(formula.Scheduled.format("W") == today().format("W") && formula.Scheduled == today() + "6d",
"09 " + formula.Scheduled.format("dddd"),

if(formula.Scheduled.format("W") == (number(today().format("W")) + 1).toString(),
"10 Next Week",

if(formula.Scheduled.format("YYYY") == today().format("YYYY") && formula.Scheduled.format("M") == today().format("M"),
"11 This Month",

if(formula.Scheduled.format("YYYY") == today().format("YYYY") && formula.Scheduled.format("M") == (number(today().format("M")) + 1).toString(),
"12 Next Month",

if(formula.Scheduled.format("YYYY") == today().format("YYYY"),
"13 This Year",

if(formula.Scheduled.format("YYYY") == (number(today().format("YYYY")) + 1).toString(),
"14 Next Year",

if(formula.Scheduled.format("YYYY") > (number(today().format("YYYY")) + 1).toString(),
"15 Later",

"16 Someday"
))))))))))))))))

1 Like

I agree, this would be a great feature. I have lots of song notes that I would like to group by album, sorted chronologically, but I can only group by album and sort alphabetical. Currently I group them by year, but that groups multiple albums together if they were released in the same year. I’d rather not add a number prefix to all my notes.