Hi everyone Not sure if this is a help request or a formula function request:
Is there an elegant way to number up entities in a formula field based on a sorting?
If this is not possible, I’d like to request a position() function, which returns the position of an entity within a collection based on a sorting.
E.g.:
Projects can have tasks assigned, each of which have a start date.
If a project has 4 tasks assigned, I would want an auxiliary (formula) field showing 1-4, depending on whether it’s the first task (based on start date) and so on.
For example, with the requested position() function, this simple formula would return what I want:
[assigned to project].[assigned tasks].sort([start date]).position(task)
It would check for each task to which project it is assigned to, then sort all assigned tasks of said project and return the position of the task.
Use case:
Contracts can have amendments, which are also contracts. The field “amendment of” indicates whether a contract is an amendment, as it will not be empty in that case.
Now my question is, if a contract IS an amendment, I would like to have an auxiliary integer formula field showing the “rank”, or the “how manyth amendment is this” (based on start date).
I use this to create unique IDs (also auxiliary field) which then goes into the name of every contract.
My workaround is nesting ifs comparing the name the contract with the name of the first/last contract within sorted collection (with first() or last()), and return 1 if it matches first, 3 if it matches last, 2 if neither. This works as long as no contract has more than 3 amendments.
This leads me to another missing function: the return of an entity of a collection which is not first or last.
Maybe the first() and last() functions could have a parameter, such that if you put in e.g. first(3), it returns the third entity and if you put in last(3) the third-last entity? Basically meaning first() = first(1) and last() = last(1)