0

Creating a Unique Sequential Record Number

I have a table (Table1) with a date field (Date). I'm entering new records where the date may be earlier than the date of a previous record and then sorting by Date to view the table in date order. So, the sorted table has a different order than if sorted by Id. I also have a formula field 'Day#' which calculates the number of days since the earliest date:

let FirstDate := min((select Table1).Date);
number(days(FirstDate, Date))

This works but then some records may have the same date and so the same value for 'Day#' so I get values for 'Day#' like 0, 1, 3, 4, 4, 6, 8, 8, 12, 13, 16

What I want is a unique sequential record number identifier, much like the internally generated Id, but in sequence when the table is sorted by date. I'd slightly prefer incrementing by 1, so 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 but that isn't necessary and so I'd settle for 0, 1, 3, 4, 5, 6, 8, 9, 12, 13, 16. As long as the record number is greater than previous record numbers when the table is sorted in date order.

 

Any suggestions, please?

2 replies

null
    • Support
    • 4 yrs ago
    • Reported - view

    What is the sorting rule when two records have the same date value?

    Birger

    • Larry_Stoter
    • 4 yrs ago
    • Reported - view

    I haven't applied a secondary sort - I thought this wasn't possible?

     

    Now you've mentioned it, I've had a look a what happens after several sorts. It seems that Ninox maintains the previous sort.

     

    So, if I apply a descending sort by Id and then apply an ascending sort by date, those records with the same date field are secondarily sorted by descending Id.

     

    I think this might allow me to do what I want :-)

Content aside

  • 4 yrs agoLast active
  • 2Replies
  • 1280Views