Get last index of the repeated data

I have a table and when a user clicks on a row an iterator is set to that row’s index and a modal opens up with a form so you can edit the information of that record. At the top of the modal I have first, previous, next and last buttons so a user can scroll through the records using the iterator and as they do the table highlights the record in the table row. I have the offset of the records also changing when the previous and next buttons are clicked and the offset needs to change.

That all works great but when a user clicks the Last button, I want to set the iterator to the last index on that page. I figure the easiest way is to get the last index and simply set the iterator to it. The problem is I haven’t found an easy way to get the last index. I’ve tried using a variable in the repeat of the table with the index as it’s value but it never gets set. I tried putting a flow set to auto-run in the table repeat that sets the value of a variable but this only gets set on page load and not if the page changes. So if the first page has 20 records the index gets set to 19 as expected but if you go to the next page of records it stays at 19 even if there are only 5 records on that page and the index should be 4.

I could do some calculations using the limit, offset total records etc but was hoping for the easy way.

I must be missing something simple or I hope I am haha.

Community Page
Last updated: