Quickly create lists of numbers or dates - Often seen as unimportant but unlocks great possibilities and automations when handled well
Before everything - What is this formula?
Sequence() allows you create lists of sequential numbers or dates. It defaults to count up by 1, but optionally you can define a by parameter and have it count up at a different rate. Try it out below:
Count to:
00
10
Count by:
0
2
List of Generated Numbers:
13579
First - let’s just learn how it works.
The Sequence() formula is like saying:
Hey Coda, Can you generate a list of numbers for me? Ill just give you a starting point, ending point and occasionally Ill tell you to count up by a number other than 1
Sequence() is a formula that takes the following arguments:
Start
This is the number you will start counting from. Often it will be 1 but it can technically be any number you like
End
This is the number your counted list will end at. Be careful! If you choose 1,000,000 or some wildly huge number it could cause your doc to slow!
By
This is the number your list will count up by. It is an optional argument and defaults to 1 if you do not input anything
Second - Where and how to use this
sequence() can seem slightly useless - or one of the lesser formulas. But to be honest, sequence is likely in my top 10 used formulas. I use it for what I call back-end or automation needs. Here are two examples of where and how I use sequence, but as you play with them yourself you will begin to find a lot more!
Creating a list of dates
In almost all my docs I create a hidden page called Date Controls that holds in it canvas based formulas containing the relative dates of the current week, previous week, current month, and previous month. As an example, here is a canvas based formula for ThisWeek. And here is the formula I wrote to create that list:
Now that I have a list of every date in a week that is named ThisWeek , I can create easy filters or buttons to quickly filter a table to contain only dates from ThisWeek. View my
to see these buttons in action. Each button references a list of dates created by sequence() to quickly filter a table.
Quickly adding rows to a table
Often times I want to quickly add a mass amount of rows to a table. Use cases include:
Create a table with 100 rows or 1000 rows to stress test a document
Create a table with 1 row for every day in the year
Heres and example table with one rows in it. Press each button to see how it automatically adds rows all possible because of sequence (Then click into images below the button to see the formulas I wrote inside these buttons)
Add 25 Rows
Add All Dates from this Month
Reset Table
Quickly Add Rows
Example Power Formula
Warning - Formulas like this are a bit advanced! But shows you what is possible when you start to combine different formulas together.
This formula specifically uses sequence() to search a Random Persons Table, find the ones who are between the ages of 20-29, and then list their info in a digested way for easy viewing.