Skip to main content

I need to create a list with consecutive numbers. I.e.: I need the following values in one field: 
Value of a certain field + 1, Value of a certain field + 2, Value of a certain field + 3, Value of a certain field + 4 etc.

So if the field has a value of 10 the results would be: 
11, 12, 13, 14 etc.

What’s the best way to get these numbers? I was wondering if the “Spreadsheet-style formula functions” or a Python script in Zapier would be the best way to do this. 

Thanks for help.

Hi @michael291 

Both options would work, but the Code step will save Tasks.


Hi @Troy Tessalone thanks! Do you have an example for that? I am not so experienced with Python and I already took a look on Google but couldn’t find anything similar.  

Thanks for help


Hi @michael291!

Here’s a bit of a hack-y way to do it but it works 🙂 Not sure how any times you have to add to that value but you can use Google Sheets like this:

Then you will get each of those values in the output of this step:

This is mostly because I’m not that great with code, so I find ways around it 😛 


@michael291 

You could also use this Formatter > Numbers > Perform Math Operation > Add step

 


@nicksimard Thanks, but I thought there would be a solution without Google Sheet (i.e. doing a Spreadsheet-style formula etc.). 

 

@Troy Tessalone I had that before. But I needed 9 single steps to get 10 consecutive numbers (based on the first number). I.e. 9 (is the base) and the following numbers 10, 11, 12 etc. So I thought there would be a solution with Python or a Spreadsheet-style formula to save a few steps within the Zap. 

 


@michael291 

Give this Code a try...

 

Returns

 


Hi @Troy Tessalone you are great!!! I owe you three beer for that. Absolutely perfect!!

 

That’s even better what I was looking for. I have added your JavaScript code snippet below for other people who are interested in it… 

 

 

 

Here’s the code snippet of the JavaScript… 

 

var INPUT = parseInt(inputData.INPUT); // sets variable value as a number
var INCREMENT = parseInt(inputData.INCREMENT); // sets variable value as a number
var BASE = parseInt(inputData.BASE); // sets variable value as a number
var COUNT = parseInt(inputData.COUNT); // sets variable value as a number
var RESULT = ]; // defines an empty array

while (BASE <= COUNT) // sets conditions for loop to execute while condition is true
{
INPUT = INPUT + INCREMENT; // increments value each time
RESULT.push(INPUT); // adds new value to array
BASE = BASE + INCREMENT; // increments value each time
}

RESULT = RESULT.join(); // converts array to comma separated string
output = g{RESULT}]; // returns specified variables