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.
Many thanks in advance for your tips.
(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 :slightly_smiling_face:
2022-03-12_23-14-37

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 :slightly_smiling_face:

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 :wink:

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 :slightly_smiling_face:

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.