How to assign ID value based on acending Dates?

I have 10 entries and I need assign them IDs from 0 to 9, based on ascending dates.
Do you know how to do it?
I’m using the following formula to get an ordered list of dates:

thisTable.date.Sort()

But now I’m stuck, as I can’t find any function to find the position of a value in the array.

Do you know any workaround?
Thanks!

Hi @Andr,

Welcome to the Coda Community!

Here’s a formula that might help…

thisTable.Sort(false,thisTable.[Date Completed]).Find(thisRow)-1

This will sort the table by the column [Date Completed], then it will find the location of that particular row. The Find() formula starts at “1”, so I added -1 to the formula to have it start at 0.

3 Likes

Hi @BenLee ,
thanks a lot, I completely overlooked the find() function.
I added an initial sorting by RowID in order to avoid index change when the user modifies the sorting order of two identical dates. This way the final indexing should be more solid. Thanks again, cheers

thisTable.Sort(True,thisTable.RowID).Sort(True,thisTable.data).Find(thisRow)-1

1 Like