Power Apps SEQUENCE Function

Description

The SEQUENCE function creates a range of numbers as a single column table. This could be a continuous range like the numbers from 1-to-100 or non-continuous range such as [2, 4, 6, 8 10]. Ranges of dates and letters can be produced as well.


Syntax

Sequence(records, start, step)

  • records – Required. Quantity of numbers in the sequence.
  • start – Optional. Starting number of the sequence. Default is 1.
  • step – Optional. Incremental value. Default is 1


Examples


Numbers

A table with all numbers from 1-to-10

Sequence(10)
Output: [1,2,3,4,5,6,7,8,9,10]


A table with all multiples of 10 from 0-to-100

Sequence(10, 0, 10)
Output: [0,10,20,30,40,50,60,70,80,90,100]


A table with numbers from 10-to-1

Sequence(10, 10, -1)
Output: [10,9,8,7,6,5,4,3,2,1]



Letters

A table of all letters A-to-Z

ForAll(Sequence(26, 65, 1), Cha\'r(Value))
Output: [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]



Dates

A table of the next 7 days starting 2020-01-01

ForAll(Sequence(7), Date(2020, 1, Value))
Output: [1/1/2020, 1/2/2020, 1/3/2020, 1/4/2020, 1/5/2020, 1/6/2020, 1/7/2020]


A table of the next 5 Saturdays starts 2020-01-04

ForAll(Sequence(5, 4, 7), Date(2020, 1, Value))
Output: [1/4/2020, 1/11/2020, 1/18/2020, 1/25/2020, 2/1/2020]


A table of the first day of each month in the year 2020

ForAll(Sequence(12), Date(2020, Value, 1))
Output: [1/1/2020, 2/1/2020, 3/1/2020, 4/1/2020, 5/1/2020, 6/1/2020, 7/1/2020, 8/1/2020, 9/1/2020, 10/1/2020, 11/1/2020, 12/1/2020]


A table of the last day of each month in the year 2020

ForAll(Sequence(12), DateAdd(Date(2020, Value, 1), 1, Months) - 1)
Output: [1/31/2020, 2/29/2020, 3/31/2020, 4/30/2020, 5/31/2020, 6/30/2020, 7/30/2020, 8/31/2020, 9/30/2020, 10/31/2020, 11/30/2020, 12/31/2020]


A table of all of the days in the month of January for the year 2020

ForAll(Sequence(Day(DateAdd(Date(2020, 1, 1), 1, Months)-1), 1, 1), Date(2020, 1, Value))
Output: [1/1/2020, 1/2/2020, 1/3/2020, 1/4/2020, 1/5/2020, 1/6/2020, 1/7/2020, 1/8/2020, 1/9/2020, 1/10/2020, 1/11/2020, 1/12/2020, 1/13/2020, 1/14/2020, 1/15/2020, 1/16/2020, 1/17/2020, 1/18/2020, 1/19/2020, 1/20/2020, 1/21/2020, 1/22/2020, 1/23/2020, 1/24/2020, 1/25/2020, 1/26/2020, 1/27/2020, 1/28/2020, 1/29/2020, 1/30/2020, 1/31/2020]


Random

A random number between 1-and-100

First(Shuffle(Sequence(1, 100, 1))).Value
Output: 67 (changes to another random number each time)

Leave a Reply

Your email address will not be published.