# Is there something like a record counter?

Is there something like a record counter?
Let me try to explain this.
Right now I have a sheet/table where I have a field with a date.
This is the date of entry.
I have some columns in which I count the last 7 days and use the values of that date in a template, so I can use it for Quickchart.
This works great if every day I input a new record with a date and a value.

But now I was thinking, how about if I skip one or two days, then the counting of the last 7 entries is not working.
So I was looking for something like a record counter.
That every time a new record is added, the counter increases.
Then I could use that counter to count the last 7 entries.
Then I am sure I always have the last seven entries.

Somewhere I saw something with a rollup and count.
And a column that adds a 1 to that count.
But then, how would I place the new number in the newly created row?

Or maybe someone has another idea on how to get the last 7 entries.
I hope my question is clear.
(I am still busy learning Glide, so please be as clear and detailed as possible. Thanks)

this is very simpleâ€¦ create a number column, call it counterâ€¦
add another column rollup maximum value from counter column
add another math column call it max counter plus 1â€¦ and the function will be rollup maximum + 1, now every time you make a new record, set the counter column with the value from the column max counter plus 1.

@Uzo, thanks but it is only working half.
I have created the number column and called it counter
Then I created the rollup column and called it RollupMax and pointed it to the counter column
Then I created the math column and called it â€śCounter+1â€ť
In there, for the configuration, I had put â€ścounter+1â€ť and for the replacements, I had put counter and let it point to the counter column.
And then it stops.
In the counter column in the first row, I placed the number 1
In the â€śCounter+1â€ť column it shows 2
But how do I get that number 2 to the counter column every time a new row is added?
As a test, I had 4 rows and place the number 1 to 4 in that column
When I added a new row, nothing happened.
The Rollup column goes to 5, and the â€ścounter+1â€ť goes to 6
And the counter column stays at 4 and the next row is empty.
I had made a screenshot and hopes it shows what I am trying to explain

I see that you did not follow my instruction precisely, your mistake is that you should add 1 to the rollup max column not to counterâ€¦ change that and it will work wellâ€¦ column Counter+1 should have all numbers the same.

1 Like

Try something like this:

1 Like

For this use case, I think the Row Index method is the simplest approach.

7 Likes

this is great! I did not think of it. how did you come up with thatâ€¦ very clever!

Thanks for sharing! @Darren_Murphy, now I can do webhooks directly from glide without waiting for glide to write the value in GS! Wowâ€¦ my Apps gonna be so fast!

Thanks, but I canâ€™t take credit. It was @11183 that came up with the idea. And yeah, itâ€™s a great technique - Iâ€™ve already found many many uses for it.

2 Likes

Thanks @Darren_Murphy
This works

There is no problem later when the column â€śAllRowIDsâ€ť is getting too big?
I mean, that there are too many RowIDs in the array?

good pointâ€¦ depends on how they store joined data

I think Iâ€™ve seen Jason mention a character limit. I canâ€™t recall what it is, but itâ€™s something crazy like billions (maybe trillions?) of characters. Probably not something you have to worry about

Keep in mind also that this is computed data, so it doesnâ€™t actually impact the â€śsizeâ€ť of your app.

1 Like

Thanks
Good to know

Itâ€™s 1 million.

Considering a rowID is 22 characters long, it has to get to 45455 row IDs for it to break, I reckon.

4 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.