When creating a formula for grouping or sorting, I want Bases to use one value for sorting and a different value for displaying.
Proposed solution
When editing a formula, rename the existing “Formula” field to “Display formula”.
Add a new field named “Sort formula” below the “Display formula” field and use “optional” as the placeholder.
When Bases evaluates a formula for sorting, it will first use the sort formula and then fallback to the display formula when not provided.
Current workaround (optional)
There is no workaround. For example, I cannot display only a relative time (string) but use the full date and time (numeric) when sorting or grouping by the same column.
You can sort by a field that isn’t displayed. No need for an extra layer on top of it, if I’m understanding your use case.
Say you want to sort by a property’s values as they’re written in the YAML but show a custom display. Enter the property name for sorting. Then create a property formula with your desired format and display that as a column.
Or vice versa.
I’m not sure that you’re talking about this, but just in case: One place you do need a workaround is when you want to display a group title that doesn’t suit your desired group order. For that, a bit of html() “display: none;” on your secret sorting text can give you control over both the display and the group order.
Sorry that wasn’t clear, I am primarily interested in this feature for grouping.
As I was working on a response, I realize that I need 3 separate things. I don’t think I properly covered that need in my OP. Using file.mtime as an example, I need:
the ability to group by file.mtime.format("YYYY-MM-DD")
the ability to sort the group by file.mtime
the ability to display the group as file.mtime.format("MMMM Do, YYYY")
Could using html() achieve this? If it can, could you please provide an example formula?
Revising my request, I would probably request a new function:
group(
key: number | string,
sort?: number | string,
display?: number | string | Link
)
The sort and display values would default to key if no value is provided.