Store a variable on the same scenario, add up at each execution, choose a specific flow when it reaches a number, then resets the variable

What I’m trying to do is rather simple:

In my flow, every time it executes, it registers data to Google Sheets.
I want that, every time it registers data 10 times to Google Sheets, it to follow a specific path, then reset that count.

So, it’d be like that

Executed, Add Google Sheet Data. (01)
Executed, Add Google Sheet Data. (02)
Executed, Add Google Sheet Data. (03)
Executed, Add Google Sheet Data. (04)
Executed, Add Google Sheet Data. (05)
Executed, Add Google Sheet Data. (06)
Executed, Add Google Sheet Data. (07)
Executed, Add Google Sheet Data. (08)
Executed, Add Google Sheet Data. (09)
Executed, Add Google Sheet Data. (10), send an SMS saying HEY!
Executed, Add Google Sheet Data. (01)
Executed, Add Google Sheet Data. (02)
Executed, Add Google Sheet Data. (03)

And so it goes.

I’m on Core plan, but can change if needed.

Welcome to the Make community!

The output of the sheets Add a Row module has a row number.

Screenshot_2024-02-23_220230

You can use it to check if it has run 10 times by using the built-in mod operator.

Screenshot_2024-02-23_220212

By using the “row” number variable, you do not need to use any additional modules or operations.

3 Likes

Oh, this is very nice! Good idea, I haven’t considered using it like that. I’ll definitely use this in other scenarios

But I believe that in this one automation in particular, it wouldn’t do; And it’s totally my fault for not being very descriptive.

So, my Google Sheets data actually comprises from two automations:
First, one from users that registered with us (adds row after row)
Second, one from users that actually replied to us (It goes after already present rows and updates)

The first automation goes linearly. An user registers, Google Sheets adds a row, then the next users gets the next row. In this case, the mod operator would work! Thanks, I’ll use this in other scenarios where this would apply :grin:
But the second automation, the user could reply at random times, and the actual row number might vary with time, because it’s a search row/update row operation (as I add the “has replied” information to the row the client’s in)

I’m actually trying to change that second one. The user replies to us, I want it to count one. Second user replies, it marks as two. After 10 replies, it should do an action (which I demonstrated by sending an SMS), then reset the counter/variable.

The issue with using the mod operator in that scenario is that the row number doesn’t increase linearly. The next run could be Row 1, but the next could be Row 16, then Row 8, after that Row 10 (and the 10th execution would incorrectly run) and so on.

What I was thinking about was that, in the end of the second automation, it would add a +1 to a variable, and when that variable reaches 10, a filter would check if it’s equal to 10, which would then proceed to “send the HEY! SMS” and reset the variable back to 0, to start all over again.

Once again, thanks for the great suggestion, though!
As I need this running ASAP, I’ll just add another Google Sheets “Add Row” module, create a dummy sheet just to count these replies, and use your suggestion for the time being.
I believe there’ll be a more “elegant” solution than this workaround, but for now, I’ll do as you suggested, just to have it working at the moment!

3 Likes