Relative record numbers in a table
I want to grab a subset of a table. Then display the subset in a view and have the view numbered from 1 to the count of records in the view. In other words, I want the view to have a field containing the numbers 1 through 10 if the subset view has 10 total records. Seems like this should be simple, but I’m just missing something!
14 replies
-
Hi Is this what you are looking for?
https://docs.ninox.com/en/tutorial/basics/row-numbers-and-ids
They call this the "always visible row number" not to be confused with the record id.
Regards John
-
Hi If I have understood what you want correctly, one solution I have come up with is the following:
let t := this; let arrayIDs := for loop1 in (select Table) order by number(Id) do loop1.Id end; let i := 0; while item(arrayIDs, i) != t.Id do i := i + 1 end ; i + 1
-
I saw that. But that refers to tables! I think I’ve got it figured out. What I wanted was ROW numbers in a View. The default view has ID numbers as the first column and NO ROW NUMBERS. When you are using a view as a temporary window into a table that will be erased and repeatedly repopulated, it’ll come up with ever increasing ID numbers and no row numbers. I was able to force a formula in the view back into a 1, 2, 3, to x format of row numbers by subtracting the view’s first row id number from each row’s id number which gives a formula with a 0, 1, 2, to x-1 value then simply add 1 to attain a field that gives the view’s row numbers formula the required 1, 2, 3, to x format. Thank you for responding!
-
Maybe this old post helps...
-
As you say, it's a special case and I am not sure if I completely understand your code. I think your post has brought to the surface an interesting problem to solve. As I mentioned before Ninox does not display row numbering in a View element.
My solution above refers to a View element in a form or a Page.
So, my question is what is the best workaround if we want to add a row numbering column to a View element in a form or a Page?
-
Hi all.
Be aware that a select statement in a formula needs a reason to trigger, usually when a non-formula field changes in value, but it's always a risky strategy. I would only use a select statement in a button or trigger.
Regards John
-
Hello ,
I think we've got to the bottom of the issue. We were both trying to solve the same problem!
Your code works perfectly in the case where the record IDs are strictly sequential, i.e. no deletions have been made to the table since its creation.
On the other hand, I tried to come up with a solution for the case where deletions have been made, so that the IDs are no longer consecutive.
Both solutions use a select statement, which I agree with isn't the best approach.
Best wishes
Content aside
- Status Answered
- 4 mths agoLast active
- 14Replies
- 78Views
-
4
Following