Skip to main content

How to Create a List of Numbers in Power Apps with Sequence

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

Sequence makes a table of numbers. Sequence(5) gives 1, 2, 3, 4 and 5; give it a start and a step, and Sequence(288, 0, 5) counts every five minutes of a day, from 0 to 1,435. Together with ForAll, it builds lists such as every time of day for a drop-down.

The example is the Overtime Timesheet app, which uses Sequence to build its list of start and finish times.

Syntax​

Syntax
Sequence(Records [, Start [, Step]])
ArgumentMeaningDefault
RecordsHow many numbers to make, from 0 to 50,000required
StartThe first number1
StepHow much each number adds to the one before; negative counts down1

The result is a table with one column, named Value (Sequence function).

Prerequisites​

A table can't be shown in a text control as it is, so each example joins the numbers into text with Concat (How to Join Table Values into Text in Power Apps with Concat). I put each formula into a text control's Text for a moment; Studio's preview strip, under the formula bar, shows the result.

Example 1: Count from 1​

Any text control → Text
Concat(Sequence(5), Value, ", ")

Sequence(5) starts at 1 and adds 1, five times:

The formula bar with Concat(Sequence(5), Value, ", "), the preview strip reading 1, 2, 3, 4, 5 with Data type text, and the text control on the canvas showing 1, 2, 3, 4, 5

Example 2: Choose the Start and the Step​

Any text control → Text
Concat(Sequence(6, 0, 5), Value, ", ")

Six numbers, starting at 0, each 5 more than the last:

The formula bar with Concat(Sequence(6, 0, 5), Value, ", "), the preview strip reading 0, 5, 10, 15, 20, 25 with Data type text, and the text control showing 0, 5, 10, 15, 20, 25

Example 3: Every Five Minutes of a Day​

A day has 1,440 minutes, so every five minutes is 288 numbers: 0, 5, 10 and so on up to 1,435.

Any text control → Text
CountRows(Sequence(288, 0, 5))

The formula bar with CountRows(Sequence(288, 0, 5)), the preview strip reading 288 with Data type number, and the text control showing 288

The example app turns those minutes into times of day with ForAll: How to Build a Table in Power Apps with ForAll.

Common Mistakes​

MistakeWhat happensDo this instead
Expecting Sequence(5) to start at 0It starts at 1Pass a start: Sequence(5, 0)
Reading a column called anything but ValueThe column doesn't existUse Value
Putting the table straight into a text control's TextA table isn't textJoin it with Concat, or count it
Asking for more than 50,000 numbersMicrosoft's limit is 50,000 recordsKeep Records within 0 to 50,000

Troubleshooting​

SymptomLikely causeFix
One number too few or too manyRecords is the count, not the last number0 to 1,435 every 5 is 288 numbers
An empty tableRecords rounds down to 0, such as 0.9Use a whole number
The numbers go the wrong wayStep is negativeUse a positive step to count up

FAQ​

What is Sequence used for?​

Microsoft's reference pairs it with ForAll to repeat something a number of times, or to turn numbers into other values, such as the next ten days with DateAdd.

Can the step be a decimal?​

Yes. Microsoft's examples include Sequence(4, -100, 0.5).

Conclusion​

Sequence(Records, Start, Step) makes a one-column table, Value, of evenly spaced numbers: Sequence(288, 0, 5) is every five minutes of a day, ready for ForAll to turn into times.

Additional Resources​